How I can change script of MouseLook, Use GetComponent() instead.
function Start () {
if (rigidbody)
rigidbody.freezeRotation = true;
originalRotation = transform.localRotation; }
//WARNING!!! 'UnityEngine.Component.rigidbody' is obsolete. Property rigidbody has been deprecated. Use GetComponent() instead. (UnityUpgradable)
Answer by SpaceManDan · Sep 27, 2015 at 06:25 AM
To access a rigidbody you need to use get component now.
Rigidbody myRigidbody = transform.GetComponent<Rigidbody>();
function Start () {
if (Rigidbody)
Rigidbody myRigidbody = transform.GetComponent();
} // like this?? But now I also have warnings... // ';' expected. Insert a semicolon at the end. // found ';'. // Unexpected token: ). // ';' expected. Insert a semicolon at the end.
I think you are going to have some other issues after this but to clarify about storing a rigid body using java script it works like this.
//create a rigidbody variable
var rb: Rigidbody;
//store a rigidbody inside the variable.
function Start()
{
rb = GetComponent.<Rigidbody>();
}
//an example of using the newly stored rigidbody
function Update()
{
Debug.Log(rb.transform.name);
}