- Home /
 
it is not possible to invoke an expression of type int
What am I forgetting here:
 #pragma strict
 
 var spawnDistance : int;
 var prefab : GameObject; 
 var character : GameObject; 
 
 function HarnessObject (HarnessAnimation : AnimationClip)
 {
     if (animation.Play("HarnessAnimation"))
     {
     yield WaitForSeconds(7);
     var prefab = spawnDistance(0, 1, 0);
     prefab.transform.parent = character;
     }
 }
 
              Answer by HarshadK · Jul 02, 2014 at 02:15 PM
The reason for error is that your 'spawnDistance' variable is of type int and you are trying to use it as a function in your line of code below
 var prefab = spawnDistance(0, 1, 0);
 
               Not sure what you are trying to do here by the way. :-Q
Ha ha, thanks for the info. I just discovered I was supposed to use a Vector3 or something where it would spawn. What I was trying to do is when the animation is played in another script, that the 2nd prefab would spawn on the player. Thank you for your help.
@$$anonymous$$iraSensei Thanks! Just plain luck nothing else. ;-)
Answer by KiraSensei · Jul 02, 2014 at 02:19 PM
You are forgetting to tell us at what line is the error :)
Hopefully for you, it is quite obvious : spawnDistance is declared as an int (line 3) and is used as a method with three int arguments (line 12). It is also not very clean to declare prefab twice (line 4 and 12).
Your answer