[NOOB Q] How to start a timeline upon collision?

B

BlakeNBitz

Guest
Hey y'all, I'm pretty new to game maker and programming so apologies in advance..

I want to have my obj_Exit, to run a timeline upon collision with obj_Player. I set up a timeline that would wait say... 120 steps then switch to next level. Is my code wrong? Is there an easier way to do this with alarms?

Here's what i did:

obj_Exit:

create event
timeline_index = tl_Endlvlanimation;
timeline_position = 0;
timeline_running = false;

collision event w/ obj_Player
timeline_running = true;



my timeline (if info's needed)
tl_Endlvlanimation

moments/actions

step 0
//wait

step 120
room_next(rm_CS2);


Thanks for any help you can give :)
 

DT Mark

Member
In this case, it would be easier to use alarms, since you're only executing code (go to the next room) at the end of the timed event.

Upon collision with the player, set the alarm[0] to 120:
Code:
 alarm[0] = 120;
Then, in the events tab of your object, add the event 'alarm 0', and put the piece of code that is used to go to the next level:
Code:
 room_goto_next();
The alarm will automatically decrement up until 0, then execute the code that you put in the 'alarm 0' event.

I suggest reading more about alarms in the manual:
https://docs.yoyogames.com/source/dadiospice/000_using gamemaker/events/alarm event.html
 
B

BlakeNBitz

Guest
In this case, it would be easier to use alarms, since you're only executing code (go to the next room) at the end of the timed event.

Upon collision with the player, set the alarm[0] to 120:
Code:
 alarm[0] = 120;
Then, in the events tab of your object, add the event 'alarm 0', and put the piece of code that is used to go to the next level:
Code:
 room_goto_next();
The alarm will automatically decrement up until 0, then execute the code that you put in the 'alarm 0' event.

I suggest reading more about alarms in the manual:
https://docs.yoyogames.com/source/dadiospice/000_using gamemaker/events/alarm event.html
Thanks for the info, I assumed alarms would probably be better in this situation. I just don't know them well enough yet. Ill definitely look this over, Thanks again!
 
Top