- Home /
Java Script - Out Parameter
Hey Community, I've got a problem in Java Script: If I write this Code:
function FindTarget(){ var hit : RaycastHit; var ray : Ray; ray.origin = transform.position; ray.direction = target.position - transform.position;
canAttack = false;
var relPosition : Vector3 = target.position - transform.position;
if(Physics.Raycast(ray, hit , relPosition)) { if(hit.collider.gameObject.transform == target) { canAttack = true; } }
I'll get this error:
Mono: Assembly Loader loaded assembly from location: 'C:\Program FilAssets/Scripts/Enemy.js(68,19): BCE0023: No appropriate version of 'UnityEngine.Physics.Raycast' for the argument list '(UnityEngine.Ray, UnityEngine.RaycastHit, UnityEngine.Vector3)' was found.
Is it because of the out parameter of the variable "hit" or because of MonoDevelop?
Thanks in advance, Sebastian
Answer by Jessy · Mar 28, 2011 at 05:50 PM
Is it because of the out parameter or because of MonoDevelop?
No. It's because there is no version of Physics.Raycast that takes a Vector3 as its third parameter. You need a float there, or just two parameters. I can't offer you alternate code because I don't know what you're trying to do, with that parameter.
Ok thanks! This is the range of the Raycast ^^ It have to look like this: Physics.Raycast(ray, hit , 10)
Your answer
![](https://koobas.hobune.stream/wayback/20220613115338im_/https://answers.unity.com/themes/thub/images/avi.jpg)