- Home /
Animation play when player collides/hits an GameObject
So basically I've been doing many researches on Unity Answers for the following topic, I couldn't really find one at all. I've managed to find a script that changes scenes once you collide with an object, but now I've been spending hours editing my script, I can't get it to work. There's a short time-out before you change scenes, it takes 3 seconds once you've touched the object in order to swap scenes.
So far, here's the script of the "scene swap":
private var NL = false;
function OnControllerColliderHit(hit:ControllerColliderHit) {
if(hit.gameObject.tag == "OnTouch Reset")
{
Debug.Log( hit.gameObject.tag );
yield WaitForSeconds (3);
NL = true; } }
function LateUpdate() { if(NL) {
Application.LoadLevel(1);
NL=false;
}
}
It could be just a easy change, but I'm obviously lost with the script.
Any help is truly appreciated.
-LittleL0L
Do you get the 'OnTouch Reset' or other stuff in debug.log? If you aren't getting that, look at the criteria for a ControllerColliderHit and make sure you meet that.
It works perfectly fine, and of course it does change scenes.
Your answer
Follow this Question
Related Questions
How do I get to display Timetaken to finish the the game scene on the final scene? 1 Answer
Playing animation when picking up an object. 2 Answers
Change animation depending of distance 1 Answer
Changing the scene when animation ends 3 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers