Hey Unitarians,
What I have is a player, and what I want is that when the player moves over a specific tile, the tile detects that the player is right above it, and freezes the player in the position until the user sets him free.
I’ve got the freezing all set up, but what I can’t figure out yet is how exactly I can have the tile detect the player right above it. The player moves in the x and y axises. The z-axis remains constant for all objects in the scene. This is the code I have so far:
if(transform.position.x == player.transform.position.x &&
transform.position.y == player.transform.position.y - 1)
{
Debug.Log ("Player is above me");
// player is directly above this tile
pausePlayer = true;
}
I’m thinking of using raycasts, but I have absolutely NO idea how to use those things at all. If you are using raycasts, it’d be great if you could write some code so I can understand. If you are writing code, it’d be preferred if it was in C# but I’m sure once I get the concept I can translate from UnityScript if needed.
Also note:
Having a trigger collision will NOT work. I’ve tried, but it simply does not work with the gameplay.
Thanks in advance!
YomanAwe