How to get actor to die when squished

stan_mcginnisstan_mcginnis Member, BASIC Posts: 18
edited June 2018 in Working with GS (Mac)

I am making a platformer game where the player can ride a moving platform, which travels horizontally, between two still platforms. I want the player to die if he gets crushed in between the moving platform and the still platform, instead of just glitching through the moving platform. I have tried many different ways but can never get the player to consistently die when crushed.

Best Answers

  • CORE GameCORE Game Posts: 280
    Accepted Answer

    There are many way to do it, I can give you one which might not be the best practice but, you can constrain the player X and Y to public attributes PlayerX and PlayerY , then create 2 invisible actors and let them follow the player (one a bit behind the player another in front of the player (call them Front / Back collider) and make it shorter a bit than the player so it won't touch while walking with the platform.
    if the collider (back or front) touches the platform then he is between the platforms.
    I will think of another way too and will let you know

  • stan_mcginnisstan_mcginnis Posts: 18
    edited September 2018 Accepted Answer

    Thanks! oops didn't mean to mark this thank you comment as an answer..

Answers

  • Triangularity GamesTriangularity Games Founder/Owner MarylandMember Posts: 140

    You could have a rule something like:
    When the two platforms are colliding and the player.Y is below where it should be (i.e. below the platform.Y+(platform.height/2)
    ->Then here you can do whatever you want to the game...

    Something like this. Hopefully this helps.

  • stan_mcginnisstan_mcginnis Member, BASIC Posts: 18

    I already tried that, it makes they player die whenever they is touching the side of thr platform even if he is not getting squished.
    I tried doing this with a platform width too, but it didnt work because the platform width/2 only updates when the player is touching the moving platform so if the player touches it, waits until it moves a bit and then touches it again, they will die before the platform width/2 updates,

Sign In or Register to comment.