Search Unity

unity 5 compiler erors

Discussion in 'Scripting' started by aaronhm77, Apr 17, 2015.

  1. aaronhm77

    aaronhm77

    Joined:
    Nov 22, 2012
    Posts:
    65
    does any body know how to read and figure out the new Unity 5 compiler errors?

    i can not figure them out

    they all say something like this;

    Assets/PropulsionPhysics/Scripts/PropelRigidbody.cs(19,33): error CS0619: `UnityEngine.Component.rigidbody' is obsolete: `Property rigidbody has been deprecated (means not approved or to express disapproval, not allowed etc). UseGetComponent<Rigidbody>() instead. (UnityUpgradable)'

    i use to be able to do the complier errors, now with unity 5, i have no clue how to fix them,

    does any body know how to fix them?

    thankx
     
  2. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    It's actually telling you what to do in the error.

    Instead of writing something like this:
    Code (csharp):
    1.  
    2. rigidbody.AddForce(force);
    3.  
    you need to do this
    Code (csharp):
    1.  
    2. GetComponent<Rigidbody>().AddForce(force);
    3.  
    Or better yet

    Code (csharp):
    1.  
    2. Rigidbody rb;
    3.  
    4. void Start()
    5. {
    6.     rb = GetComponent<Rigidbody>();
    7. }
    8.  
    9. rb.AddForce(force);
    10.