• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED]Moving platform help needed. Player slides off platform!

pixeltroid

Member
The platforms move the way I want them to but whats happening is that when the player jumps on the moving platform, he just slides away to the right!

objects used:

1. obj_movingplatform
2. obj_player
3. obj_blocker (an invisible object placed at the end of the moving platforms path)


-------------------------------------

1. for obj_movingplatform

Create:

Code:
vspeed = 2
Step:

Code:
with (obj_player)
{
if (place_meeting(x,y-4, obj_blocker))
{
with (obj_movingplat)
{
vspeed = 2;
}
}
}
Collision with obj_solid (used for floors, walls, ceilings etc):

Code:
if (vspeed > 0)
{
vspeed = -2;
}

else
{vspeed = 2;
}

if (place_meeting(x,y-1,obj_player))
{
obj_player.y -=5;
}
Collision with obj_blocker that limits movement of platform is same as above



2. For obj_player

Collision with obj_movingplatform
Code:
{
move_contact_solid(direction, 3);
vspeed = other.vspeed;
}

What am I doing wrong with the code???? How can I modify the code to make it work?
 
Last edited:
T

ThePropagation

Guest
using the built in variables cause problems. and you don't need the blocker object. set the platform in the center position of where you want it to be and in its create event say

Code:
dir = choose(-1, 1);
timer = 0;
then in the step event

Code:
timer += 1

if timer > (when you want the object to change direction)
{
     timer = 0
     dir *= -1;
}

x += dir * (whatever speed you want it to be)
unless you have walls then do the place meeting thing.

As for the player moving with the platform just have the normal player movement actions then on the player put

Code:
if place_meeting(objPlayer.x, objPlayer.y + 1, objPlatform)
{
     x += (speed of the platform) * objPlatform.dir
}
sorry I just saw you have a vertically moving platform, just swap the x's and y's and you'll have the same solution
 
T

ThePropagation

Guest
Do you have any platform collision restriction on the player character? you can remove that
 

pixeltroid

Member
Do you have any platform collision restriction on the player character? you can remove that

hey... your method worked....I just changed "x" to "y" (since its a vertical platform).

Just one thing...how do I make it work with obj_blocker? Im asking because its easier to control the distance the platform moves...and that way I dont have to calculate timers!
 
T

ThePropagation

Guest
if place_meeting(objPlatform.x, objPlatform.y + vertSpeed, objBlocker)
{
dir *= -1;
}
 
T

ThePropagation

Guest
the vSpeed would be how far ahead you want the platform to turn around. Glad you got it working
 
Hi, Im using Dnd, my player just slides off the platform when they stand on it. I just give the moving platform a direction to move in, and when it gets to the end of its path, it reverses its direction, but when the player stands on the platform, they just slide off, even when the moving platform is a solid.
 
Top