I tried to attach a spotlight to a camera, but I cannot drop the camera to the variable in the spotlight-script as described in the beginners manual.
:?
Who can help me with this?
Some questions:
- The script is attached to a GameObject correct?
- What is the type of the variable? How is it defined?
I am talking about the examples of the “Introduction to scripting with Unity” Tutorial. You can find it at URL: http://download.unity3d.com/support/Tutorials/2%20-%20Scripting%20Tutorial.pdf
- Yes, the Javascript is attached to the spotlight by dragging it with the mouse into the it’s icon in the 3D-view, just like I did it with the cube.
- The variable is called target and is of Type Transform. You can find it at the buttom of page 4. I am trying to attach the camera, but it will not show anything above the variable name.
So you’ve got your script attached to your spotlight and you can see the variable is not assigned in the inspector. When you drag your camera object from the Hierarchy view to the target variable in the inspector, what happens? Does the variable highlight before you let go of the mouse button? Does the camera item you are dragging spring back to its original location when you let go of the mouse button?
I was trying to move the camera object to the variable target in the light grey script field at the top of the inspector. Now I found the variable at the buttom of the inspector and linked the camera to it. Everything works fine now. Thanks!
![]()