- Home /
Which is better for player movement: physics or translation
I have a player object that moves forwards as well as sideways. It moves in a narrow x range sideways depending on user input whereas in the forward direction it moves automatically without input.
I am seeking whether applying forces is the right way to move it or should i move it using transform.translate?
It depends on your game - we have a tile-based RPG game and we used to move the player (and all NPCs) using physics moving over a terrain but we found that this was overkill, especially once we had moved to flat environments. We removed all of this and created animations for the movement tile to tile, using animation events to jump the player to the new tile when the animation has completed.
In-between these two methods we used coroutines to Lerp the player from one position tot the next, but I felt that animations would be cheaper and that player and NPC positions would be easier and cheaper as we are running on mobile. If you are targeting the desktop it might not be as much of an issue for you.
it all depends on your game, your platform and the freedom of movement you need to allow your player.
Answer by DisruptionGames · Jul 11, 2012 at 08:26 AM
It all really depends on what you are looking to achieve.
I find for less Physics/Intense Realism based games. You would want to use Translation. Translation also is a bit easier to compile from looking at it (Seeing what is happening) if you take the time to get it. Physics based can get a bit glitchy if its not done perfect/right. But physics does add the simple ability to add outside forces to the player.
Overall: I use a bit more of Translation just because its a bit simpler to work with and isn't labor intensive on the system. As far as Pre-Made Controllers go, I would say its about 50/50 down the middle. But I have seen more noble Translation based Controllers than Physics Based (Rigidbody).
Its kind of hard to judge what you mean by the context of translation and physics. So I went on a tangent and assumed Physics meant Rigidbody and Translation meant Character Controller.
I think he means moving the GameObject using this.transform.Translate().
But it's worth making a distinction that a CharacterController is designed for very specific movement and in itself, is not affected by physics, but character controllers are a special collider of sorts that will respect the colliders in your game and move along them.
A CharacterController is not affected by rigid bodies, but they can be used together, though getting character like behaviour with a rigid body based controller is difficult.
The Unity docs discuss rigid bodies and character controllers here:
http://docs.unity3d.com/Documentation/Components/comp-DynamicsGroup.html
Yes I mean this.transform.translate().
I am using forces on a rigidbody on the player to move now, and the issue is controls are not crisp enough. In sideways motion, when the player receives input to reverse movement direction, it takes some time to do so.
Is there some way to make the player more responsive while using physics, or would translate be better?
PS I am not using character controllers
Just using a native character controller without Rigidbody forces is quite easy. If you are looking for a crisp feel to it you can base movement with move directions and based off of Horizontal and Vertical Input (WASD/Arrow $$anonymous$$eys) and add a higher gravity to them in the Input $$anonymous$$anager.
So CharacterControllers are a convenience component, so I would first ask whether you COULD use them. The problems you're experiencing are the difficult issues mentioned in the link above and I cannot help with that but I would as yourself if you need your player to be affected by other forces - could the CharacterController work for you?
translate works better. a character controller could work but i want to apply forces to it as well to simulate floating of the player.