- Home /
Question by
wgrene80 · Apr 24, 2016 at 07:35 AM ·
2d2d-platformerbooleandebug.logcollision-detection
C#: Trying to debug.log message when player collides with object
2D Platformer : I'm trying to have the console log a message to me that the player has crossed over a square on the floor. I tried using a bool and a collision method to do this but so far the only result I can get is all squares sending me the message at the start before the player even collides with them. heres the code code and if you need more info on my problem just ask.
using UnityEngine;
using System.Collections;
public class NewTile : MonoBehaviour {
//public GameObject player; (not using yet)
//public Sprite Tile; (not using yet)
private bool SpawnedTile = false;
void Start () {
}
void OnCollisionEnter2d(Collision2D coll) {
if (coll.gameObject.tag == "Player")
SpawnedTile = true;
}
void Update () {
if (SpawnedTile == true)
Debug.Log ("crossed");
}
}
Comment