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

Platform issues (GM7)


Recommended Posts

Hello everybody!

I'm still working hard on BrazSonic 2 engine (that uses the old 360 engine) for a long time, and only now I decided to extend the moving platforms system to work in whatever moving solid (by x and y cordinates, paths and even hspeed/ vspeed that I only used before).

This is my try:

if instance_place(x+(dsin*mask_radius),y+(dcos*mask_radius),obj_moving)

platform=instance_place(x+(dsin*mask_radius),y+(dcos*mask_radius),obj_moving)

if (platform!=noone)

{

if ground

{

x -= platform.xprevious - platform.x;

y -= platform.yprevious - platform.y;

action=0;

ground=true;

}

}

but it doesn't work, even detecting the platform... only works in vertical platforms.

Also, I'm really wanting to know how seesaws and tilting floors (that inclines when you're in their edges) works.

Anyone have idea?

Link to comment
Share on other sites

if (platform!=noone)
{
if ground
{
x [b]+=[/b] platform.x - platform.x_previous;
y [b]+=[/b] platform.y - platform.y_previous;
action=0;
ground=true;

}
}

also, dont use the built in previous variables. instead, at the beginning of each step, update your own with the current x and y.

  • Like 1
Link to comment
Share on other sites

Well, for the detecting problem, you should probably use a tiny bit bigger than the mask_radius. Also, you don't need the first if, since that'll be covered with your "if(platform != noone)".

platform = instance_place( x + dsin*(mask_radius+3), y + dcos*(mask_radius + 3), obj_moving);

As for the rest of your code, I don't know if setting action to 0 and ground to 1 is necessary, since you're already on the ground. I'm not sure if using the xprevious/yprevious values will work perfectly, but if the moving platforms are just using path movement or something simple, it should be fine.

if (platform!=noone)
{
    if ground
    {
        x -= platform.xprevious - platform.x;
        y -= platform.yprevious - platform.y;
    }
}

If you want to add jumping momentum (i.e. whenever you jump/fall from a platform, the speed of the platform will be added to the your speed, so that it looks more realistic), what I'd do is I'd only check for the platform if your on the ground, then if you're not on the ground and the platform variable does not equal noone, that means you just jumped off/fell off, so you'd add the change in position to your speed:

if(ground)
    platform = instance_place( x + dsin*(mask_radius+3), y + dcos*(mask_radius + 3), obj_moving);

if (platform!=noone)
{
    if ground
    {
        x -= platform.xprevious - platform.x;
        y -= platform.yprevious - platform.y;
    }
    else
    {
        hspeed -= platform.xprevious - platform.x;
        vspeed -= platform.yprevious - platform.y;
    }
}

Link to comment
Share on other sites

Now with your code it's working perfectly!!

Actually, I'm using two kinds of parent solids for moving platforms: a "block" (essential for crushing platforms and bridges) and "thru platform" (only for simple floating platforms).

Now, here goes:

if ground

{

if instance_place( x + dsin*(mask_radius+3), y + dcos*(mask_radius + 3),obj_movingfakefloor)

platform=instance_place( x + dsin*(mask_radius+3), y + dcos*(mask_radius + 3),obj_movingfakefloor)

if instance_place( x + dsin*(mask_radius+3), y + dcos*(mask_radius + 3),obj_moving)

platform=instance_place( x + dsin*(mask_radius+3), y + dcos*(mask_radius + 3),obj_moving)

}

This resolved a problem that moving the character according the last moving platform that he stepped, by x-axis.

if !((instance_place( x + dsin*(mask_radius+3), y + dcos*(mask_radius + 3),obj_movingfakefloor))||(instance_place( x + dsin*(mask_radius+3), y + dcos*(mask_radius + 3),obj_moving)))

platform=0

And finally your code...

if (platform!=noone)

{

if ground

{

x -= platform.previous_x - platform.x;

y -= platform.previous_y - platform.y;

}

else

{

hsp -= platform.previous_x - platform.x;

vsp -= platform.previous_y - platform.y;

}

}

I use Rogueyoshi's previous_x and previous_y on platform's parents and worked fine (I didn't tested that using xprevious/yprevious yet).

Now I'll reduce the jumping momentum that's very high, hehehe.

Now I have a question about this instance:

bullshityx4.jpg

You have a large seesaw, that tilts gradually acording when you're at its edges. I had found a gm example about this a long time ago, but I lost that forever in my old HD>.<.

Link to comment
Share on other sites

  • 2 weeks later...

I don't use gm, but I can still try to explain to you a calculation to achieve the tilting platform.

To get the angle of the platform if you're against it:

If [Collision.Platform] is true:

Set [Angle.Platform] to:

([PositionX.Platform]-[PositionX.Player])÷[Radius.Platform]*[MaxAngle.Platform]

Put simply, this takes the distance the player is located from the center of the platform and multiplies it by the maximum amount the platform can tilt. The radius of the platform is obviously half of the width, and the max angle is the maximum amount the platform can tilt. The rest should be pretty self-explanatory; hope it helps. =>

Btw, when you're not on the platform, it's best to have it rotate its angle back to 0 for a nice transition. Here's a little example of how it would be coded in MMF2 if it helps:

If [Collision.Platform] is false:

Set [Angle.Platform] to:

[Angle.Platform]-([Angle.Platform]÷[interpolation.Platform])

This is a really simple way to have an interpolated angle return back to normal. The current angle is subtracted by the exact amount needed to return to normal DIVIDED by an interpolation value which gives the return inbetween steps. The higher you make the interpolation value, the smoother and longer the return will be.

Once again, I hope you can make something out of this even if it's mostly similar to the way I code in MMF2. =]

( P.S. The equation for interpolation would normally be:

([Angle.Platform]-[DestinationAngle.Platform])-([Angle.Platform]÷[interpolation.Platform])

but since the destination angle in this case is 0, it's not needed. )

Link to comment
Share on other sites

  • Recently Browsing   0 members

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