Character jumps while colliding anywhere with platform

saad1993saad1993 Member, BASIC Posts: 47

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 Member Posts: 1,188

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

  • saad1993saad1993 Member, BASIC Posts: 47

    @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 Member Posts: 1,188

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

  • IceboxIcebox Member Posts: 1,485

    @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 Member, BASIC Posts: 47

    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 Member Posts: 1,485

    @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 Member Posts: 2,239

    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.