• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

GML How do I stop my character for 1 second when it collides with an object?

arganaca

Member
I wanted to stop my character for 1 second after it crashed into a wall.
I've seen several videos of alarms but it's not working.
Can someone help me?

Sorry ... I'm new here and on Game Maker Studio 2 too xD
 
You could use a cool down variable. Basically, add a variable that reduces to zero in the set event if it's greater than zero.

If there's a collision, you set the value to 60 (if you're using 60 fps, but you may want to use actual time passed if it has to be exact) and add a if statement around your movement that prevents it from running if that variable is less than or equal to zero.
 
You could have inside of ur collision code to add a number to a cooldown variable. then on ur movement keys put an if statement that says

if (cooldown = 0)
{
...move code...
}
if(cooldown > 0)
{
cooldown--;
}

you will have to use big numbers depending on what ur room speed is. if its set to 60 then every 60 cooldown means 1 second

im not great with gml either but i hope this helps
 
Top