- Home /
Line Renderer & Raycasting SOS !!!
hi everyone,
I'm working on a player(robot), who can shoot lasers with the eyes, i've made this following script, but unity give me 4 errors, I've searched everywhere and unity don't change, i've everytimes this errors :
Assets/Robot/Scripts/Aim Head.js(15,36): BCE0023: No appropriate version of 'UnityEngine.Physics.Raycast' for the argument list '(UnityEngine.Ray, System.Type, float)' was found.
Assets/Robot/Scripts/Aim Head.js(16,63): BCE0019: 'point' is not a member of 'System.Type'.
Assets/Robot/Scripts/Aim Head.js(18,36): BCE0023: No appropriate version of 'UnityEngine.Physics.Raycast' for the argument list '(UnityEngine.Ray, System.Type, float)' was found.
Assets/Robot/Scripts/Aim Head.js(18,69): BCE0019: 'point' is not a member of 'System.Type'.
This is my bad script :
var leftEye : Transform;
var rightEye : Transform;
var laser : LineRenderer;
var maxDetection : float;
var shotKey : KeyCode;
function Update () {
var hit = RaycastHit;
var rayl = new Ray (leftEye.position, leftEye.forward);
var rayr = new Ray (rightEye.position, rightEye.forward);
if(Input.GetKeyDown(shotKey)) {
var laserClone = Instantiate(laser, leftEye.position, leftEye.rotation) as LineRenderer;
var SecondLaserClone = Instantiate(laser, rightEye.position, eyeRight.rotation)as LineRenderer;
laserClone.SetPosition(0, rayl.origin);
SecondLaserClone.SetPosition(0, rayr.origin);
if (Physics.Raycast(rayl, hit, maxDetection)) {
laserClone.SetPosition(1, hit.point);
}
if (Physics.Raycast(rayr, hit, maxDetection)) {
SecondLaserClone.SetPosition(1, hit.point);
}
}
}
Please explain me, i'm lost !
P.S : sorry for my bad english , i'm a french man.
Thanks for advance. Regards
Answer by robertbu · Apr 24, 2014 at 05:55 AM
On line 21, 'eyeRight.rotation, should be 'rightEye.rotation'.
And 14 should be:
var hit : RaycastHit;
Your answer
![](https://koobas.hobune.stream/wayback/20220613143435im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Raycast wrong direction - really weird 1 Answer
Perspective issue with railgun/raycasting 0 Answers
LineRender: I can't seem to be able to set the start and end positions of the line 0 Answers
Grapple Gun? 1 Answer
line renderer in raycast with one starting point (mouse input) and multiple end point 2 Answers