Hi!
So, just a simple and quick question that I can’t find an answer to. And yes I’ve tried searching the answers and the forums but didn’t find anything related.
When I’m using tags to check if a enemy is colliding with a waypoint, and also when I try to check if my player is colliding with a wall, the if-statement returns true even if there’s no collision with a collider with that tag. Even if the game object with the tag is more than 3 units away, and thus not colliding with the other object, the statement still returns true.
So I guess my question(s) is:
What could be causing this?
Is anyone else experiencing this problem?
Is there a solution to this?
Thanks in advance!
Erik
Edit:
For those of you who wanted the code:
Player code:
function OnCollisionStay (col : Collision)
{
if(col.gameObject.FindWithTag("Terrain"))
{
canJump = true;
}
else
{
canJump = false;
}
}
Enemy code:
function OnCollisionEnter (col : Collision)
{
if (col.gameObject.FindWithTag ("Waypoint"))
{
//code for switching walking direction
}
}
And yes, both the player and the enemy are colliding with something else, the ground (“Terrain”). BUT, as they both are colliding with the terrain as soon as I start the game and the statement doesn’t return true until a certain position in the game, I don’t think that this is the issue. If it was, then the statement would return true as soon as I started the game (i.e. as soon as they hit the ground).