4
\$\begingroup\$

I got stuck with this problem; I have searched Unity forums but could not get an answer to solve it.

I am getting this error:

The type or namespace name RigidBody could not be found. Are you missing a using directive or an assembly reference?

using UnityEngine;
using System.Collections;

public class playercomponent : MonoBehaviour {
    
    public RigidBody rb;
    
    void start()
    {
        this.rb =  GetComponent<Rigidbody>();
    }

    void FixedUpdate()
    {
        float moveHorizontal = Input.GetAxis("Horizontal");
        Float moveVertical = Input.GetAxis("Vertical");
        Vector3 movement = new Vector3 (moveHorizontal,0.0f,moveVertical);
        
        rb.AddForce(movement);
    }
}
\$\endgroup\$

1 Answer 1

17
\$\begingroup\$

it should be Rigidbody, not RigidBody

\$\endgroup\$
4
  • \$\begingroup\$ thanks @Leggy but in default suggestions it shows RigidBody ?? what is that \$\endgroup\$
    – Divya
    Apr 13, 2015 at 9:15
  • \$\begingroup\$ what does suggest you RigidBody by default? in Monodevelop? \$\endgroup\$
    – Leggy7
    Apr 13, 2015 at 9:35
  • \$\begingroup\$ yes ,it shows "RigidBody" with capital "B" when we write something in unity, default suggestions \$\endgroup\$
    – Divya
    Apr 13, 2015 at 9:51
  • 2
    \$\begingroup\$ Still helpful in 2021. Such a silly mistake. \$\endgroup\$ May 10, 2021 at 6:55

Not the answer you're looking for? Browse other questions tagged .