Rigidbody spasms and hovering
The player (with a rigidbody, character controller, and capsule collider) has this script attached to it:
public class PlayerMovement : MonoBehaviour
{
public float speed = 200;
public float jumpHeight = 200;
public string jump = "space";
public CharacterController cc;
public Rigidbody rb;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(jump))
{
if (cc.isGrounded)
{
print("jump");
rb.AddForce(0, jumpHeight, 0);
}
}
}
private void FixedUpdate()
{
rb.AddForce(Quaternion.AngleAxis(transform.rotation.y, Vector3.up) * new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")) * speed * Time.deltaTime);
}
}
And the player then floats 3 units (it starts on the ground). The output window is not being spammed with 'jump', and the player cannot be moved via input controls. The only other script is not attached to any gameObject, and there is only one scene. If I try to move the player when the game is running in the Scene view, it skyrockets to about 378 units above ground. None of these issues occur if I freeze y position on the rigidbody
Your answer
Follow this Question
Related Questions
Converting my Character Controller Movement to Rigidbody 1 Answer
How to create smooth jump with rigidbody.addforce? 2 Answers
Model keeps falling apart when I apply a rigidbody 0 Answers
Problem with "pushing" objects with FPS Controller 0 Answers
Moving a player character that has ragdoll colliders/rigidbodies 0 Answers