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

Wooden Crate physics (GM6)


Chaos Rush

Recommended Posts

I'm having trouble with some physics. So lets say that there's 3 crates stacked up on top of each other. Sonic destroys the crate at the bottom. Then the crates above the one that Sonic just destroyed should be falling, right?

Well I'm having trouble replicating that. Here are the object properties:

Name: objWoodCrate

Parent: objParentBreakableTerrain

Create Event:

Gravity               = 0;
GravityForce = 0.2185;
Ground = true;
Limit = 64;
MaxLimit = y+64;[/CODE]

Step Event:

[CODE]
vspeed = Gravity;
if (Ground = false) Gravity += GravityForce;
if (Ground = true) Gravity = 0;

if (place_meeting(x,y+Limit,objParentBreakableTerrain) || place_meeting(x,y+Limit,objParentTerrain))
{
Ground = true;
} else { Ground = false }

if (y > MaxLimit) y -= 1;[/CODE]

To help explain, here's some pics:

1. Here Sonic looks up at the stack of crates.

2. Sonic destroys the bottom row.

3. Here Sonic looks up only to realize that the crate above only moved a few pixels down, and that Newton's laws are lying.

Link to comment
Share on other sites

Try replacing you Step event code with this:

    y += Gravity
    if (Ground = true)  Gravity = 0;
    else                Gravity += GravityForce;

    if (collision_point(x,y+Limit,objParentBreakableTerrain,0,1) ||
        collision_point(x,y+Limit,objParentTerrain,0,1)) {
        Ground = true;
    }
    else Ground = false;
    while (y > MaxLimit) y -= 1;

The 'place_meeting' function is probably the culprit though, as it could have counted itself when checking for collided objects. This is why I've used the 'collision_point' function, it makes sure that it doesn't count itself during the collision checking.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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