- Home /
Noob Question! Unexpected token: if.
#pragma strict
InvokeRepeating("Shoot", 0, 1);
var target : Transform;
var missle : GameObject;
var tooClose : float;
function Shoot()
if(Vector3.Distance(transform.position,target.position)>tooClose){
Instantiate(missle,transform.position,transform.rotation);
}
Could you please tell me whats wrong with my code? THANKS!
Comment
Best Answer
Answer by Dave-Carlile · Jan 04, 2013 at 05:07 PM
You need braces - { } for the body of your function.
function Shoot()
{
// your code goes here
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613090405im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
What is wrong with my RockPaperSissors script? 1 Answer
Only access door if it's not locked? 1 Answer
Uhhhh... 2D Maze Generator Help! 3 Answers
Digital Clock: Time.time > 60 2 Answers