Commit 0d90c74c authored by Luke A Smith's avatar Luke A Smith

Merge branch 'floorSwitch' into 'master'

Floor switch

See merge request !21
parents 7fb86304 804e8c42
using UnityEngine;
using System.Collections;
public class FloorSwitch : MonoBehaviour {
//Ignore sprite renderer in file and set image useing first place in list
public GameObject player;
public bool isSwitchOn = false;
public Sprite[] sprites;
public bool isSwitchBack = true;
private Collider2D pCol;
private bool charIsOn = false;
private SpriteRenderer spriteRenderer;
// Use this for initialization
void Start ()
{
//Sets sprite to first frame
pCol = player.GetComponent<Collider2D>();
spriteRenderer = GetComponent<Renderer>() as SpriteRenderer;
spriteRenderer.sprite = sprites[0];
}
void OnTriggerEnter2D(Collider2D col)
{
//Debug.Log(col.name);
if(col == pCol)
{
//Debug.Log("somthing moving on");
//Turns on bool and changes sprite
isSwitchOn = true;
spriteRenderer.sprite = sprites[1];
}
}
void OnTriggerExit2D(Collider2D colE)
{
if (colE == pCol && isSwitchBack == true)
{
//Debug.Log("somthing moving off");
//Turns off bool and changes sprite
isSwitchOn = false;
spriteRenderer.sprite = sprites[0];
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment