- Home /
This question was
closed Dec 23, 2018 at 11:09 AM by
hexagonius for the following reason:
moving Rigidbodies is a well covered topic. check out other answered questions
Question by
rkaundinya · Dec 23, 2018 at 08:59 AM ·
charactercharactercontrollercharacter controllercharacter movementterraincollider
Character is running through terrain instead of over it
I've been having trouble getting my player character to run over terrain. I've tried a few different methods including transform.Translate, rb.Velocity, and rb.MovePosition. Velocity and MovePosition both give me a problem of the character speeding across and also floating above the terrain and ground. Translate does not give me these problems, but will not allow the character to run up terrain and only works properly when gravity is turned off and IsKinetic is turned on.
Here is the script I am using currently - please do let me know if any of you see a way to modify this to allow the character to run over terrain:
public float speed;
private Rigidbody rb;
void Start () {
rb = GetComponent<Rigidbody> ();
}
void FixedUpdate() {
moveMonkey ();
}
void moveMonkey()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
transform.rotation = Quaternion.LookRotation (movement);
transform.Translate (movement * speed * Time.deltaTime, Space.World);
}
Comment