Hello to everybody, I need a suggestion from people more experienced than me in Unity: in my game, gameobjects are soldier miniatures moving around a terrain (very simple!) and I need them to behave in this way;
-
Objects are moved only by direct input of the player. So units should move where requested with no acceleration, no bouncing, nothing. They should move taking into account only the gravity that pushes them onto the terrain.
Instead, when I make them move with the Translate command, all physics rules are applied, making them bounce, etc…
-
The second problem I have is that i want gameobjects to simply stop moving when they try to move against another gameobject (without bouncing, pushing the other object, etc). Is this possible?
Sorry if this is a silly question, but I cannot find an answer.
Many thanks
Hey there,
I think what you can do to take care of the bouncing problem is mark the units’ rigidbodies as kinematic. Here’s what the Component Reference says for kinematic rigidbodies:
“If enabled, the object will not be driven by the physics engine, and can only be manipulated by its Transform.”
For your second question, it seems that you need to detect when the game objects collide and stop them from moving any further. Maybe you can use the “isTrigger” property of Colliders. Again, the Component and Script References are your friends Script Reference says:
“A trigger doesn’t collide with rigid bodies. Instead it sends OnTriggerEnter, OnTriggerExit and OnTriggerStay message when a rigidbody enters or exits the trigger.”
I hope this helps, good luck.
To me it sounds like you need a character controller… I don’t know much about them… but they’re basic colliders that can have gravity applied to them, but will not react to physics. They also have handy dandy built in stuff like maximum slope and stuff… I would suggest using those if you want units to behave in the way you described.