x


Run script when player steps in location

Hi

I am making a maze game.

I want when the player gets to the middle of the maze, to run script. How should I do this?

I basically want to stop the time and go to another scene, but this I will figure out later.

Thanks, Chris

more ▼

asked Feb 14 '10 at 09:09 AM

cmos gravatar image

cmos
467 29 40 54

Hi cmos,

I see your question has been answered by Sebas, please do upvote it and mark it as accepted for future reference. Cheers!

Feb 14 '10 at 08:40 PM Ricardo
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Put a game object where you want this to happen (can be empty game object). Attach a collider (e.g. cube or sphere) to the game object and set the collider to IsTrigger. You can then use the following function:

function OnTriggerEnter (other : Collider) {
 //load your new scene here or do whatever is needed;
 Application.LoadLevel (1);//or whatever the number of your new level is
}
more ▼

answered Feb 14 '10 at 09:17 AM

Sebas gravatar image

Sebas
4.1k 12 18 45

Wow.... that worked amazing. I am also really impressed with the response times in this forum. Thanks a lot!!

Feb 14 '10 at 10:00 AM cmos
(comments are locked)
10|3000 characters needed characters left

In attempting to do this I got some errors so this is how I got around it.

I had to add the scenes to the build settings (under the file tab) and attached this script to the trigger (game object).

var trigger: GameObject;

function OnTriggerEnter (other: Collider) {
    Application.LoadLevel ("Level_2");//the name of your scene in the project panel
}
more ▼

answered May 29 '12 at 11:50 PM

mcfetrmatt gravatar image

mcfetrmatt
21 6 10 12

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5276
x1019

asked: Feb 14 '10 at 09:09 AM

Seen: 1482 times

Last Updated: May 29 '12 at 11:50 PM