0
\$\begingroup\$

I have an object, in this case a space ship, resting on a floor or platform object. The bottom of the space ship is flat, and is resting flush with the flat surface of the platform object (due to my collision detection). Now obviously, the player is able to move the space ship by pressing up. The player is also able to turn the ship (image_angle and direction) by pressing left or right, which transfers the speed to that direction if they are flying. However, in the scenario mentioned above where the ship is currently resting flat on a flat surface, if the player presses left or right, the ship still rotates and the sides clip into the surface of the platform, which causes collision detection to essentially glue the ship to the platform. How can I use collision detection to allow the player to still rotate the ship while it is resting on a flat surface, but instead of clipping, have the object perhaps "roll" or fall over?

here is my collision detection:

// Gravity
if (vspeed < 10) vspeed += .02;

// Collision detection
if (place_meeting(x, y + vspeed, obj_block))
{
    while (!place_meeting(x, y+1, obj_block))
    {
        y += 1;
    }
    vspeed = 0;
    hspeed = 0;
}
\$\endgroup\$
-1
\$\begingroup\$

Place your rolling code in the if part of the Collision algorithm and Clipping code in the else part of the Collision algorithm

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.