Actor touching the bottom of a platform/stopping a jump

I'm still making the endless runner I mentioned in another post and I'm encountering a bug which could cheapen the experience.

If I jump below a platform and touch it it reset my jump count like if I landed on the top of it. I don't want that to happen and want a rule that if the top of the player touches the bottom pixel of the platform, then the player's jump count would be 0 and the player would lose.

How would I go about this? I've dabbled with this rule but come unstuck as it sometimes makes me stop jumping when I legitimately touch of the top of the platform.

Comments

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    I think you can check your players linear.velocity.Y during the rule that checks if the player touches the ground to re-set the jump.

    If the players linear.velocity.Y is > 0 it's moving up so don't re-set the jump. This assumes your player would only be moving up when it's jumping.
  • MasakoXMasakoX Member Posts: 16
    Thanks for your input jamie. I added the condition to the player's 'flag that I've retouched the surface' and when I did it, it prevented me from jumping at all. I want the player to jump if it's on the top of the platform but when it smashes into the bottom of it.

    I'm actually using your 'Endless Runner' tutorial on your course as a base and adapted it from there.

    I got my code for the player here - http://i44.tinypic.com/2crautv.png and here http://i42.tinypic.com/aza22t.png

    Many thanks for your help.
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    @MasakoX, check out the attached sample. I've used the file from my Advanced platformer movement tutorial as a base. Check out the Hero actor, in the Reset Jumps Rule I've added a new condition that checks the Hero's Linear Velocity Y, this stops the jumps from resetting when hitting a platform from below. See if following that example will work for your game.
  • MasakoXMasakoX Member Posts: 16
    I added it like you did and it had no effect. The trouble is that the platforms respawn like in your endless runner tutorial and when I slam into the platform's bottom, it constantly resets. I'll link the file here. I don't suppose you could take a gander at it please.

    [URL=http://wikisend.com/download/342464/PixelatedEndlessRunner_v0.2b.zip]PixelatedEndlessRunner_v0.2b.zip[/URL]
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    @MasakoX, I've attached an updated project. Here's what I updated to get it working:

    I turned the Reset Jumps Rule off in your player and added a Rule like it to the two platform actors. This allows you to check to see if the player is above or below the platform since you were already tracking the players X and Y locations in a Game Attribute.

    To make the players jumping still work right I added two new Game Attributes, Jumping and jumpCount. These are just like and perform the same function as the Actor Level Attributes you had by the same name. I just had to move them to Game Level so they could be accessed by the Platform actors when the players jump needs to reset. I added a couple notes in the platform rules so you can see what exactly I added.

    It seems to be working fine now, check it out and let me know your thoughts.
  • MasakoXMasakoX Member Posts: 16
    Super. Thank you so much, Jamie. I really appreciate it. This was hurting my brain so much. Another thing I had issue with was wanting to spawn a missile to then target the player which they player would have to dodge. So how would I spawn a random projectile?
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    edited July 2013
    @MasakoX, There are different ways of approaching that but one way is to ad an invisible 'game controller' actor and have that actor spawn a new projectile every X number of seconds. Then since you are already tracking your players X and Y locations you could use a Move To behavior to move the missile toward the player. That is the basics of tracking the player, but it can and will likely get more complex depending on exactly what you want to happen. But hopefully that will get you going in the right direction.
Sign In or Register to comment.