- Home /
I need help with Javascript
I am doing Raycast shooting scripts this is my script (java script):
pragma strict
var Range : float = 1000;
var Force : float = 1000;
function Start () {
}
function Update () {
if(Input.GetKey(KeyCode.F)) RayShoot();
}
function RayShoot (){
var Hit : RaycastHit;
var DirectionRay = transform.TransformDirection(Vector3.forward);
Debug.DrawRay(transform.position , DirectionRay * Range , Color.blue);
if(Physics.Raycast (transform.position , DirectionRay , hit , Range))
It says as an error notice thing:
Assets/FPS Scripts/Java Scripts/RauShoot.js(40,1): BCE0043: Unexpected token: .
You're getting a compiler error on line 40 of RauShoot.js
-- the parser isn't able to handle a period character, it looks like.
You've probably made a syntax error at or around that point in the script.
It doesn't look like that part of your code is included, here, which we'll probably need to see if you want more specific help. You can post the code on PasteBin or a similar website if you can't figure out the code formatting features here.
@dmaster Heres one thing from this section of code
var Hit : RaycastHit;
if(Physics.Raycast (transform.position , DirectionRay , Hit , Range))
You forgot to capatalize hit, since your var is uppercase, and you have lower case in the if statement. Thats not the prob though. Post line 40 please
Answer by benjimazza · Jun 06, 2012 at 10:01 PM
This was pretty simple, Where you see 'hit' put Force there instead, also you need to end that line with a ';' then underneath the last line put a '}' ,, basically the last line should look like this.
if(Physics.Raycast (transform.position , DirectionRay , Force, Range));
}
Hope this helps :)
@benjimazza that doesnt make sense/ why would force be there? the overload would be the raycast hit. also why did you put a ; at the end? the purpose of an if statement is to be able to do something with the hit, otherwise you might as well not have that line at all.
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
I can do this in JS or not ??? 2 Answers
Gun Script Help 2 Answers
Script not working (Java script) 2 Answers