Which has better performance? Add force or Change position?


#1

Hi everyone,

I’m creating a platformer game with moving platforms (up/down and left/right).

In order to make the platforms move I think about two alternatives: add force to the platform or change the position of the object.

Both alternatives works properly but, in terms of performance (RAM, CPU use), anyone knows which is more efficient?

Do you recommend one or another because of anything else?

(The game is being created for mobile devices)

Thank you!


#2

I prefer forces over position, and i always use forces is my personal opinion but i think the movement is smooth using forces.


#3

Hi!

Quite frankly I don’t know. I would say make the game, test it on mobile and change if needed.


#4

The force use the position, also the force compute some factor like the velocity, the gravity, etc…
So if you don’t want these thing you can directly use set the position.


#5

Forces are of course slightly more cpu intensive but not that much. They are just a direction, and every frame the position is changed newCoordinateInThatDirection * TimeDelta() (if instant force then it moves by newCoordinateInThatDirection after substracting TimeDelta() from it).

This is out of memory I may be not 100% right but forces are really not that complicated and cpu intensive.

Tho forces from physics 2 are much more cpu intensive as there is a whole physics engine processing it