Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

GM and vertical moving platforms


Recommended Posts

okay im having trouble finding a decent tutorial on how to do vertical moving platforms in game maker. all of them work fine until it comes time for the player to move back down. it just lets the player fall rather then bring the player with it which causes problems for those with games that have a different falling sprite then a standing sprite. and often i find they have it so when you are moving up when it comes time to move back down the player actually bounces up before going down. does anyone know how to do actual working vertical moving platforms? or ones that move in all directions, like ones that go in circles?

Link to comment
Share on other sites

For motion, a path might be your best bet for making the platform move in a circle. For up-down platforms, I use this code for motion:

nformation about object: obj_platform_ver

Sprite: <no sprite>
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: obj_walls
Mask: <same as sprite>

Create Event:
COMMENT: Variables
execute code:

var xdir;
var turn;
var noturn;

COMMENT: Setup
execute code:

xdir=1;
turn=0;
noturn=0;

Alarm Event for alarm 0:
execute code:

if (noturn=1) noturn=0;

Step Event:
COMMENT: Movement
execute code:

if (xdir=1) vspeed+=0.08;
if (xdir=0) vspeed-=0.08;

if xdir=1 {
if (vspeed>2.3) vspeed=2.3 }

if (xdir=0) {
if (vspeed<-2.3) vspeed=-2.3 }

Collision Event with object marker:
execute code:

if (noturn=0) {
xdir=!xdir;
noturn=1;
alarm[0]=60; }
[/CODE]

This lets you place a small marker wherever you want the platform to change direction. It also causes the platform to slow down and speed up smoothly. As for how to stay put on platforms, pass. I'm as interested as you are.

Link to comment
Share on other sites

Before Sonic's movement (in the Begin Step event) execute this code:

follow = instance_place(x,y+2,obj_movingPlatform);

After Sonic's Movement (in the End Step event) perform this code:

if(follow)
{
    x += follow.x - follow.xprevious;
    y += follow.y - follow.yprevious;
}

That works for platforms moving in any direction, but works best with paths and might not work it you do complicated movement for the platform using your own variable (in which case you should make your own x/yprevious).

Link to comment
Share on other sites

  • 1 month later...

i know this thread is old, but since you still need help with this, i will do it gladly.

first make a parent object called objMovingPlatform, and make its parent object your platform parent object(if you dont use one, just make the your solid parent object its parent).

next, in the create event of objMovingPlatform, put in this code:


previous_x = x;
previous_y = y;
[/CODE]

after that in the end step event put this:

[CODE]
previous_x = xprevious;
previous_y = yprevious;
[/CODE]

now, make a new object and call it objlvl1Platform, and make objMovingPlatform its parent. also give it whatever sprite/mask you want it to have.

next, in your player's step event, put this code:

[CODE] // ---- Moving platforms ---------------------------------------------------------------------
objHandle = instance_place(x,y+2, objmovingPlatform)// change the y+2 part to suit your character's collision mask;
if (objHandle != noone && onGround)
{
x -= objHandle.previous_x - objHandle.x;
y -= objHandle.previous_y - objHandle.y;
}[/CODE]

next, place your platform and fire up your game.

change varaible/object names to suit your game.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...