My objects coordinate system doesn’t seem to rotate correctly when it collides and turns when hitting other objects. For example, it will move, but it will move as if it were facing the original direction before the collision. I have tried adding torque through script and it seems to act fine via that method.
#pragma strict
function Start () {
rigidbody.AddTorque(Vector3(0, 250, 0));
}
var w : boolean = false;
var s : boolean = false;
function Update () {
if(Input.GetKeyDown(KeyCode.W))
{
w = true;
}
if(Input.GetKeyUp(KeyCode.W))
{
w= false;
}
if(Input.GetKeyDown(KeyCode.S))
{
s = true;
}
if(Input.GetKeyUp(KeyCode.S))
{
s = false;
}
if(w && rigidbody.velocity.z < 10)
{
rigidbody.AddForce(Vector3(0, 0, 250));
}
if(s && rigidbody.velocity.z > -10)
{
rigidbody.AddForce(0, 0, -250);
}
}
I agree with robertbu in the Transform.forward that is how I move all my objects in my games
– KingKongFuThe AddRelativeForce() works well for my purpose. This is kind of a little side question. What makes an object not turn as easy when it hits an object? Should I turn angular drag up?
– techboysquared