Hello, I have been trying to get my object (a cube) to move forward, left, and right for a while. It has a rigid body. This is what I have been using. (Csharp)
using UnityEngine;
using System.Collections;
public class Rigidbodymovement : MonoBehaviour {
public float move = 0f;
public float turn = 0f;
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.W))
rigidbody.AddRelativeForce (Vector3.forward * move, ForceMode.Acceleration);
if (Input.GetKey (KeyCode.D))
rigidbody.AddTorque(Vector3.up * turn, ForceMode.Acceleration);
if (Input.GetKey (KeyCode.A))
rigidbody.AddTorque(Vector3.up * -turn, ForceMode.Acceleration);
}
}
This works, HOWEVER, it will start to rotate because of friction and start bouncing all over the place. Is there anyway to make it so it will slide forward instead of moving like a wheel rotating forward?
Thanks,
SonicWave