- Home /
Duplicate Question
Unknown identifier "clone"?
Hello everyone. Currently I am making a test FPS game in Unity, I'm very inexperienced as I am still learning how to do things in Unity. Right now I'm using Unity 4 and I'm trying to make my gun shoot. I got the code off of this video: https://www.youtube.com/watch?v=NPlRbxJtKxE. This is the code from the video: #pragma strict var projectile : Rigidbody; var speed = 10; function Update () { if (Input.GetButtonUp ("Fire1")) { clone = Instantiate(projectile, transform.position, transform.rotation); clone.velocity = transform.TransformDirection(Vector3 (0, 0, speed)); Destroy (clone.gameObject, 5); audio.Play(); particleSystem.Play(); }}
I realised he made a mistake (or so I think) as earlier the game would not build and run because #pragma strict was not included. Now I get 3 errors that show up saying: Assets/Standard Assets/Shoot.js(10,1): BCE0005: Unknown identifier: 'clone'. Assets/Standard Assets/Shoot.js(11,1): BCE0005: Unknown identifier: 'clone'. Assets/Standard Assets/Shoot.js(13,10): BCE0005: Unknown identifier: 'clone'. Does anyone know what the problem is? If so could you please tell me what it is so I can fix this.
Doesn't look like clone has been properly defined before it's called in Update().
There's very little valid reasons for a syntax error question like to this be posted.
https://unity3d.com/learn/tutorials/modules/beginner/scripting