Gravity Overridden

I am writing a program that has a ball jump and move side to side, but when I press the left and right arrows to make it move sideways, it overrides the gravity causing it to hover in midair. Is there any way for me to move side to side independent of the vertical movement?

Comments

  • ArchonStudiosArchonStudios Member, PRO Posts: 23
    instead of using the "move" behavior, try doing something like self.Motion.LinearVelocity.X = playerSpeed to go right, self.Motion.LinearVelocity.X = -playerSpeed to go left, and self.Motion.LinearVelocity.Y = jumpHeight to jump up. Also, instead of using the scene's gravity attribute, try placing an accelerate behavior on the player actor that you want affected by gravity, direction = 270 and speed can be whatever you want. Just make sure your Linear Velocity in the Y direction is enough to fight the gravity effect.

    In my limited experience, this should do what you want it to do. I will have to check later though to verify since this is off of the top of my head and I don't have my mac in front of me.
  • ArchonStudiosArchonStudios Member, PRO Posts: 23
    Oh also, don't forget to set Linear velocity X back to 0 when not pressing a button or your actor will continue moving that direction.
Sign In or Register to comment.