Search Unity

Affect Seperate Objects

Discussion in 'Scripting' started by krisrockwell, Oct 7, 2005.

  1. krisrockwell

    krisrockwell

    Joined:
    Oct 5, 2005
    Posts:
    8
    Hello (again),

    I have a script attached to an object. When that object is affected I would like the material of a seperate object to change (in this case simulating an object lighting when a switch is clicked). I have searched through the docs for examples of this type of manipulation without luck. Are there any example scripts or can someone point me to one?

    Thanks,
    Kris
     
  2. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    Have you read the scripting introduction. It has a short section on accessing other game objects: http://otee.dk/Documentation/ScriptReference/index.html#Accessing Other Game Objects

    And apart from the ways mentioned there, you can just have a variable in you behavior pointing to the other game object:
    Code (csharp):
    1.  
    2.    var otherObject : Transform;
    3.  
    4.  
    ... then drag the other object you want to manipulate onto it in the inspector.