- Home /
AddForce makes cube
Okay - so I have got a problem with addForce. At the moment my character is a cube which is moving around in a 3-dimensional space. However when it is on the floor it starts to roll instead of slide. I tried to deactivate gravity and let it float in the air above the course and here the sliding works perfectly fine. Now I deactivate gravity when it is on the ground, and now it only rolls over occasionally.
transform.rigidbody.AddRelativeForce(Vector3.forward * moveSpeed);
This is the code used to move my character.
Can someone help me solve this?
Answer by ForeignGod · May 08, 2014 at 09:02 PM
Go onto your rigid body and remove rotation from there, you can also add friction on your cube collider.
Im doing the exact same thing now and this works for me^^
Answer by hari ram · May 08, 2014 at 06:31 PM
relative force is used to move the object in local space whereas vector3 tries to move in world space.You may try using transform as below.
transform.rigidbody.AddForce(transform.forward * moveSpeed);
Let me know if this resolved the issue.
No it doesn't work. I changed it from Addforce to addrelative force because I need it to work on the local axis - it doesn't work in any of the cases.. :/