GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Character jumps while colliding anywhere with platform

saad1993saad1993 Posts: 47Member, BASIC

Hello everyone! So I am working on this endless runner. Pretty simple mechanics, an endless line of long platforms spawn randomly and the character jumps when touch is pressed.

The problem i'm facing is that my character jumps even when it is falling and colliding across the the middle of the platform, instead of only the top of it.

The character also seems to jerk upward when touch is pressed while it is falling across the platform. I have constrained the X position of the character to 100 so it stays in one place and the platforms move.

Is there anyway I can work around this?

Comments

  • ToqueToque Posts: 1,165Member

    Can you make a rule he can only jump when touch and collide with platform?

  • saad1993saad1993 Posts: 47Member, BASIC

    @Toque said:
    Can you make a rule he can only jump when touch and collide with platform?

    I made that rule. The problem is, the character is technically colliding with the platform when it is in contact with it from anywhere, even when it is falling through the platform. Although, the jump should only work when the character is on top of the platform.

  • ToqueToque Posts: 1,165Member

    Can you place another actor where you only want to have jump allowed. And add that rule??

  • IceboxIcebox Posts: 1,474Member

    @saad1993 said:
    the jump should only work when the character is on top of the platform.

    You can do two things ,
    first create 2 real game attributes , Player X and Player Y
    then create a boolean call it feetonground

    In your main player actor
    constrain Game.PlayerX to self.positionX
    constrain Game.PlayerY to self.positiony

    In your jump rule do this
    for example
    if key space is down and game.feetonground is true
    jump

    Now you wont be able to jump unless feetonground is true , so you need a way to set it to true.

    There are 2 ways , you can check if the player is on top of your ground actor this way
    go into your ground actor

    if game.PlayerY is >= self.positionY+self.size.height/2
    change attribute game.feetonground to true
    otherwise
    change attribute game.feetonground to false

    the other way to do it is to create an actor call it feet make it thin and small
    You want to stick it to your main actors feet.

    constrain self.positionx to game.playerx
    constrain self.positiony to game.playerY - ( half the size of your player actor)

    then put this rule if overlaps or collides with actor ground change attribute game.feetonground to true otherwise change game.feetonground to false.

    Hope all of this made sense.

  • saad1993saad1993 Posts: 47Member, BASIC

    I'm going to try that out and let you know. Thanks! =P
    Also

    @Toque said:
    Can you place another actor where you only want to have jump allowed. And add that rule??

    I tried, that. Didn't work.

  • IceboxIcebox Posts: 1,474Member

    @saad1993 I suck sometimes at explaining so ill attach a demo , the red actor is the feet actor , it only jumps when the feet actor touches the ground, even if you spam the jump button at a wall.

  • BigDaveBigDave Posts: 2,239Member

    you could also only enable to jump if linear motion y is 0

    so you cant jump while falling beeing in the jump etc

Sign In or Register to comment.