Falling Platform Troubles(Solved)

Null-Z

Member
I want to have falling platforms in my game and tried this chunk of code.

I have the parent set as the ground object.

Under the Step Event
-
triggered=false;
timer=10;

if triggered
{
if timer == 0 grav = 6;
else timer -= 1;
}
else
{
if collision_rectangle(x-10, y-50, x+10, y+50, Player, true, false) triggered = true;
}
-

But the platform refuses to fall when the player stands on it.
what am I doing wrong?
 

Slyddar

Member
Under the Step Event
-
triggered=false;
timer=10;

if triggered
{
if timer == 0 grav = 6;
else timer -= 1;
}
else
{
if collision_rectangle(x-10, y-50, x+10, y+50, Player, true, false) triggered = true;
}
-
Not sure if you've written it wrong here, but you have the triggered and timer variables declared in the step event. They need to be in the Create.
 

TheouAegis

Member
And also, since you didn't post it, make sure you actually have code that applies grav to the the platform's vertical speed. Lol
 

Null-Z

Member
I've found a solution to my problem.

Like Sly said, I put triggered and timer into create, I changed "grav" to "gravity" and set that value to 0.1, and added an instance_destroy for when it goes off-screen

It works exactly as I wanted.

thank you for you help.
 
Top