- Home /
How to load a scene on collision
I need to know how to Load a scene named, UnityZombieGameScene3 on collision. Please say if its on the collider or the character that will be colliding with it, I would prefer the script to be in Javascript, its ok if its not. Thanks
Answer by ByteSheep · May 01, 2012 at 08:06 PM
function OnCollisionEnter(col : Collision) {
Application.LoadLevel ("UnityZombieGameScene3");
}
You can also add a check to see if it collided with the right object (e.g player). This script can go on either the character or the other collider :) Bet you could have figured this out on your own though..
damn... you beat me to posting because I was hitting the script reference to try and put it into Boo script lol ... "Bet you could have figured this out on your own though.." .. exactly why I was putting it into Boo , since Javascript was requested.
Answer by Lo0NuhtiK · May 01, 2012 at 08:11 PM
Here's some Boo, just cuz' .
If it's not correct, I don't care, I don't use that language. I put more effort into making this into Boo than you did into finding an answer to this question or figuring it out in any way.
import UnityEngine
import System.Collections
class CollisionLevelLoader(MonoBehaviour):
def OnCollisionEnter(other as Collision):
if other.gameObject.CompareTag('Player'):
Application.LoadLevel('UnityZombieGameScene3')
Your answer
Follow this Question
Related Questions
Endless DeathZone??!!? 4 Answers
How do I restart a scene after a collision? 2 Answers
I need help with my enemy collision. 1 Answer
help sound on collision when key down 2 Answers