Moving bodies forward, best method?

I’m working on a platform type game where the player is always running forward. Like Badlands, Punch Quest, Robot Unicorn Attack etc. I’m using Physics for platforms and collisions. 

What’s the best method to move the character forward? Here’s the choices I came up with:

  • enterFrame applied to x
  • body:applyForce() 
  • body:setLinearVelocity()
  • body:applyLinearImpulse()

Out of these setLinearVelocity() has worked the best. 

I’m sure you already have a lot of your logic in place, but you will get a lot of suggestions telling you that you are WAY better off just keeping the player in place and moving everything around the player. You can still use physics to move the interactable objects towards your player and just move the background with transitions.

Thanks for the reply. I should have listed this method. I have been having pretty good luck moving the player object, when using physics. When not using physics, keeping the player stationary and moving the other objects has been the method.

I guess with physics you’re modeling a real world space, so it seems intuitive to move the player object through that space. For example, if the player gets hit and knocked back, or hits a wall and can not progress forward, if the player is in motion this is taken care of. Without physics these situations become harder to solve.

Since you’re using a hybrid combo of physics/non-physics, I think the body:setLinearVelocity is the best bet.

As a general bit of advice, I believe:

  1. if you’re already using physics, then use it all the way! It’s powerful and you can do a lot with the engine, so make use of those powers. :slight_smile:

  2. if you’re not using physics, then don’t use it just for one small game aspect like detecting basic “collisions”, if that same basic task could be done with non-physics detection math, for example.

Brent

Yeah, I feel the same way. Seems if you’re giving in to the overhead of phyics you might as well use it for everything. I’m thinking this would consolidate everything into the same unified system. 

That said the problem is always wrestling with physics to do what you want. There are so many options available it gets pretty confusing. 

I’m sure you already have a lot of your logic in place, but you will get a lot of suggestions telling you that you are WAY better off just keeping the player in place and moving everything around the player. You can still use physics to move the interactable objects towards your player and just move the background with transitions.

Thanks for the reply. I should have listed this method. I have been having pretty good luck moving the player object, when using physics. When not using physics, keeping the player stationary and moving the other objects has been the method.

I guess with physics you’re modeling a real world space, so it seems intuitive to move the player object through that space. For example, if the player gets hit and knocked back, or hits a wall and can not progress forward, if the player is in motion this is taken care of. Without physics these situations become harder to solve.

Since you’re using a hybrid combo of physics/non-physics, I think the body:setLinearVelocity is the best bet.

As a general bit of advice, I believe:

  1. if you’re already using physics, then use it all the way! It’s powerful and you can do a lot with the engine, so make use of those powers. :slight_smile:

  2. if you’re not using physics, then don’t use it just for one small game aspect like detecting basic “collisions”, if that same basic task could be done with non-physics detection math, for example.

Brent

Yeah, I feel the same way. Seems if you’re giving in to the overhead of phyics you might as well use it for everything. I’m thinking this would consolidate everything into the same unified system. 

That said the problem is always wrestling with physics to do what you want. There are so many options available it gets pretty confusing.