UnityNinja Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

UnityNinja CommunityLog in

UnityNinja - Video Game Development Community, including Resources, Forums, Marketplace & More.


descriptionWhy do I get an error???? EmptyWhy do I get an error????

more_horiz

Code:

if (Distance < lookAtDistance);
   {
      GetComponent,renderer.material.color = Color.yellow;
      lookAt();
   }
   


HELP HELP HELP HELP

descriptionWhy do I get an error???? EmptyRe: Why do I get an error????

more_horiz
BacN wrote:

Code:

if (Distance < lookAtDistance);
   {
      GetComponent,renderer.material.color = Color.yellow;
      lookAt();
   }
   


HELP HELP HELP HELP


Okay so have some Inconsistance with how format of a method or function is built
is base format....... not sure of your whole code but basically below is how it should look
You had semi colon at end of if(); can end this way..
look at your commas vs Period/Dots when calling object structure

Code:

public class Test : MonoBehaviour {

   public float Distance;
   public float lookAtDistance;
        Renderer renderer;   

   // Use this for initialization
   void Start () {
   
   }
   
   // Update is called once per frame
   void Update () {
      if (Distance < lookAtDistance)
      {
         renderer.material.color = Color.yellow;
         lookAt();
      }
   }

   void lookAt(){

   }
}



Also all in doubt this
http://docs.unity3d.com/ScriptReference/Renderer-material.html
Will be your primary understanding and fix
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum
power_settings_newLogin to reply