GameSalad

How to stop when colliding with a box?

I'm making an infinite platformer, where the player needs to stop when he collides with a box obstacle. The only thing that moves in the game is the ground under the player (the player.position.X is constrained). This means that I drop the box on the ground and the ground moves it toward the player like a conveyor belt. I am trying to make it so the box moves with the ground, but cannot be moved by the player AT ALL. The player can jump on top of the box or over the box (meaning he needs to be able to move on top of the box). This proves difficult when trying to use the collision behavior because the player gets stuck on top of the box and can only move when he jumps (move in the air). I have tried several approaches to this problem and none of them are accomplishing this the proper way. Any solutions? Is there a way to do this with physics? Like make the box so strong that the player cant move it no matter what, but can still jump on top of it and move on it...Any help/advice would be greatly appreciated. Thanks in advance!

Best Answers

Answers

  • tatiangtatiang Posts: 11,085Member, Sous Chef, PRO, Senior Sous-Chef
    edited August 7

    Disclaimer: platformers are not at all my strong suit

    Here's how I'd start out... (up arrow key repeatedly to jump)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Triangularity+GamesTriangularity Games Posts: 123Member, PRO

    @tatiang said:
    Disclaimer: platformers are not at all my strong suit

    Here's how I'd start out... (up arrow key repeatedly to jump)

    Kinda, but not quite. In your example, the scene moves automatically. See if you can figure out with my movement...its very weird and peculiar I've played around with the physics, and I can't seem to find a workaround.

  • tatiangtatiang Posts: 11,085Member, Sous Chef, PRO, Senior Sous-Chef

    @Triangularity Games said:
    In your example, the scene moves automatically.

    Okay, I see in your project file how you've set this up. Makes sense. I don't have a fix though, sorry!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,899Member

    Use friction. Friction needs high numbers, both the ground and box need to have an amount set or friction will not work. Also make sure your player actor has zero friction. Also make sure bounce is set to zero.

  • Twayne2Twayne2 Posts: 56Member, PRO

    real simple, just make the box have tone of density, (say, 5k.)

  • Triangularity+GamesTriangularity Games Posts: 123Member, PRO

    @The_Gamesalad_Guru
    @Twayne2

    Did you see if this worked with the test file in this thread? I've tried playing with the physics in all sorts of ways and never found a solution...let me know if either of you can. Thanks!

  • Twayne2Twayne2 Posts: 56Member, PRO

    Um the file doesn't work for me... I extracted it but the gsproj doesn't have anything, as it is just blank.

  • Twayne2Twayne2 Posts: 56Member, PRO

    wait scratch that.

  • Twayne2Twayne2 Posts: 56Member, PRO
    edited August 20

    Ok I need to know what you want the box to do when it collides with the player... does it push him back? Is there a zone behind the player that destroys him? If so then I believe I have a solution. :smile:

  • Twayne2Twayne2 Posts: 56Member, PRO

    Well I guess that you don't want the solution very much lol....

  • Triangularity+GamesTriangularity Games Posts: 123Member, PRO

    Sorry @Twayne2 , been away for a few days. The player is supposed to completely stop when he hits the brown obstacle (as if it were a big box). However, he should be able to jump over it in both directions (unless the stopper on one of the ground blocks the player from jumping backwards; left).

  • Twayne2Twayne2 Posts: 56Member, PRO

    What do you mean by completely stops? The player was never moving...

  • Twayne2Twayne2 Posts: 56Member, PRO

    ?

  • Triangularity+GamesTriangularity Games Posts: 123Member, PRO

    @Twayne2

    The player can move left and right (arrow keys) and can jump (up arrow key). When he encounters the brown box, he should stop when he hits it (the same way we would stop if we hit a large heavy box. However, he can jump and move on top of the box or over the box. This should work in both directions.

  • Twayne2Twayne2 Posts: 56Member, PRO
    edited August 22

    I would suggest adding a new attribute rule to your movement rules saying:
    (if game attribute (tracker) is 0,)
    if key press right is down:
    move.

    When the obstacle and player collide, change game attribute (tracker) to 1. Thus the ''player'' can't move, (but he can still jump.) Then figure out a way to change the game attribute (tracker) back to 0 once the player has jumped over the obstacle. Hope this helps! :smile:

  • BBEnkBBEnk Posts: 1,733Member, PRO
    edited August 22

    @Triangularity Games

    just move the player and camera then loop the scene for endless play.

    keep in mind order of operation is very important doing it this way otherwise you will get a flicker on reset, I build all my endless games like this works very well once you get the hang of it.

    heres a example might have a glitch but works you can figure out the rest.

Sign In or Register to comment.