Hey everyone, got a bit of a wierd issue.
I have my player object set up so that when it hits a trigger, it will flip 180 degrees of its current angle to face in the opposite direction, The triggers are responding in the debug console to show that they have been triggered, however, it only seems to change the direction of the object if the rotation of the y angle is 0 or 270, when it is 90 or 180 it just sails straight through the trigger instead of turning around.
It’s a bit strange since the colliders have the same tag which is recorded in the Debug log and the colliders are the same as the ones that are north and west of the object, so why does it not work for the east and south colliders.
Here is my code
#pragma strict var player : GameObject; var playerPoint : GameObject; var pressed : boolean; var startPosition : Vector3; function Start () { } function Update () { startPosition = playerPoint.transform.position; if (pressed == true) { player.transform.Translate (0, 0.2, 0); } if (pressed == false && player.transform.position !=
startPosition)
{
Return();
player.transform.Translate (0, 0.2, 0);
}
}function Return() { if (player.transform.eulerAngles.y == 0) // This works { player.transform.eulerAngles.y = 180; //player.transform.Translate (0, 0.2, 0); } if (player.transform.eulerAngles.y == 90) // This doesn't work { player.transform.eulerAngles.y = 270; //player.transform.Translate (0, 0.2, 0); } if (player.transform.eulerAngles.y == 180) // This doesn't work { player.transform.eulerAngles.y = 0; //player.transform.Translate (0, 0.2, 0); } if (player.transform.eulerAngles.y == 270) //This works { player.transform.eulerAngles.y = 90; //player.transform.Translate (0, 0.2, 0); } if (player.transform.position.x == startPosition.x && player.transform.position.z == startPosition.z) { player.transform.Translate (0, 0, 0); player.transform.position = startPosition; } }
Any ideas as to why this is?
Cheers