G
G
Grisha Nikolsky2015-11-08 15:33:47
Unity
Grisha Nikolsky, 2015-11-08 15:33:47

Why does AddForce work differently?

Hello. I was writing a simple game and ran into the following problem:
I have a cube that I want to control. It was not possible to do movement through Translate, because the cube did not interact well with other objects (it entered them and immediately jumped out), so I decided through AddForce.
After writing the following code :

if (Input.GetKey (KeyCode.W)) //Движение вперед
{
  MainRigid.AddForce(transform.forward * moveSpeed);
}

The cube did not want to move forward, but only rolled to the other side. Apparently, the force is applied in the wrong place. How to change it? If AddForce should work like this, then tell me other methods to solve the problem.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Grisha Nikolsky, 2015-11-09
@VoxelGod

I figured it out, you need to use a different physical material for the cube and the surface.

F
Flabber, 2015-11-08
@gruzincev_maksim

Do you have to roll it? Try turning off gravity in Ridgebody

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question