Commit 67682d2d authored by AndrewSmith's avatar AndrewSmith

FloorSwitch Commit

parent b1edcb29
using UnityEngine;
using System.Collections;
public class FloorSwitch : MonoBehaviour {
public Collider2D playerCollider;
public bool isSwitchOn = false;
public Sprite[] sprites;
private bool charIsOn = false;
private SpriteRenderer spriteRenderer;
// Use this for initialization
void Start ()
{
//Sets sprite to first frame
spriteRenderer = GetComponent<Renderer>() as SpriteRenderer;
}
void OnTriggerEnter2D(Collider2D col)
{
//Debug.Log("somthing moving on");
if(col == playerCollider)
{
//Turns on bool and changes sprite
isSwitchOn = true;
spriteRenderer.sprite = sprites[1];
}
}
void OnTriggerExit2D(Collider2D colE)
{
//Debug.Log("somthing moving off");
if (colE == playerCollider)
{
//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