- Home /
Please help me debugging a script!
I've got a Credits button in the menu and the credits themselves in another location. I made an animation for the camera to move there and unchecked "Play Automaticaly". And I attached this script to the Credits button:
public var myCamera : GameObject;
function Update ()
{
if (Input.touchCount > 0)
{
var ray = Camera.main.ScreenPointToRay (Input.GetTouch(0).position);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit))
{
Debug.Log(" You just hit " + hit.collider.gameObject.name);
if(hit.collider.tag == "Credits")
{
myCamera.animation.Play("Credits");
}
else if(hit.collider.tag == "CredExit")
{
myCamera.animation.Play("CredExit");
}
}
}
}
But when I turn on the scene and click on the button nothing happens! I don't know, what's the problem, tried everything! Please help me!
Comment
You can use GetComponent to access the Animation on the camera directly. Or 'Find' the camera object and make an instance.
Does the button have a collider?
Your answer
Follow this Question
Related Questions
What am I doing wrong with this attack script? 2 Answers
Activating One Part of An Animation 2 Answers
Help touch button 1 Answer
Play animation when in collider and button pressed 1 Answer
GUI.button order 1 Answer