3
\$\begingroup\$

I have a perfectly smooth cube on top of a perfectly smooth plane. I am applying a forward-force of 1 unit per second, using rigidBody.AddForce(new Vector3(0, 0, 1), ForceMode.VelocityChange). I apply this force every FixedFrame(), taking into account Time.fixedDeltaTime, of course.

When the "Use Gravity" checkbox on the RigidBody is not checked, the object behaves as expected; after exactly 3 seconds, it has a speed of exactly 3 units per second.

However, when I enable the "Use Gravity" checkbox, the object barely moves. Both the object and the surface are using Physic Materials with zero friction, and the moving object's RigidBody has zero drag and zero angular drag.

Why does this happen? And more importantly, how would I apply a force to this object so that it moves forward at, say, exactly 3 units per second, with gravity enabled?

Thank you.

\$\endgroup\$
0
\$\begingroup\$

Are you using a "frictionless" physic material or just leaving it unassigned altogether? I've learnt that an unassigned physic material still has some kind of friction resistance, along with physic materials having a diference in friction with the dynamic friction and static friction attributes.

Try creating a true frictionless physic material with these set to 0 and you should have behavior similar to an ice cube sliding along.

\$\endgroup\$
  • \$\begingroup\$ That's the thing: I am using a frictionless material, manually made. \$\endgroup\$ – flatterino Jun 13 at 17:32
0
\$\begingroup\$

You can multiply your vector3 with MoveSpeed variable. In my How to move Character according to Camera's look direction? question i've posted an answer. I'll link that so you can examine it.

  1. That's how i did:

    targetPosition = (camF * vec.y + camR * vec.x) * MoveSpeed;
    
    Vector2 targetVelocity = (targetPosition - transform.position)/Time.deltaTime;
    
    rb.AddForce(targetPosition - rbVelocity, ForceMode.VelocityChange);
    

    As you can see all i have to do was multiply my calculation with MoveSpeed variable.

  2. Here you can find whole code if you are curious.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.