Search Unity

Rigidbody not moving with basic script and frozen rotations?

Discussion in 'Physics' started by Resilo, Apr 16, 2019.

  1. Resilo

    Resilo

    Joined:
    Dec 8, 2016
    Posts:
    139
    My rigidbody uses gravity,, has mas, is not kinematic,, has frozen rotations, has gravity enabled, the character has a collider and stands on the ground just fine, the terrain has a collider to stand on. I am curious why the following script will not move the character forward or what edits i would need to make in order to have the character move with rotations frozen.


    Code (CSharp):
    1.         moveHorizontal = Input.GetAxis("Horizontal");
    2.        moveVertical = Input.GetAxis("Vertical");
    3.  
    4.         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
    5.  
    6.         myrigidbody.AddForce(movement * speedstat);