Commit 804e8c42 authored by Swado95's avatar Swado95

Updated

parent 67682d2d
......@@ -3,12 +3,15 @@ using System.Collections;
public class FloorSwitch : MonoBehaviour {
//Ignore sprite renderer in file and set image useing first place in list
public Collider2D playerCollider;
public GameObject player;
public bool isSwitchOn = false;
public Sprite[] sprites;
public bool isSwitchBack = true;
private Collider2D pCol;
private bool charIsOn = false;
private SpriteRenderer spriteRenderer;
......@@ -16,17 +19,20 @@ public class FloorSwitch : MonoBehaviour {
void Start ()
{
//Sets sprite to first frame
spriteRenderer = GetComponent<Renderer>() as SpriteRenderer;
pCol = player.GetComponent<Collider2D>();
spriteRenderer = GetComponent<Renderer>() as SpriteRenderer;
spriteRenderer.sprite = sprites[0];
}
void OnTriggerEnter2D(Collider2D col)
{
//Debug.Log("somthing moving on");
//Debug.Log(col.name);
if(col == playerCollider)
if(col == pCol)
{
//Debug.Log("somthing moving on");
//Turns on bool and changes sprite
isSwitchOn = true;
spriteRenderer.sprite = sprites[1];
......@@ -36,10 +42,11 @@ public class FloorSwitch : MonoBehaviour {
void OnTriggerExit2D(Collider2D colE)
{
//Debug.Log("somthing moving off");
if (colE == playerCollider)
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