Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by domwhu777 · Jun 06, 2012 at 09:52 PM · javascripterrorraycasterror message

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: .

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hijinxbassist · Jun 06, 2012 at 09:58 PM 0
Share

which is line 40?

avatar image rutter · Jun 06, 2012 at 09:59 PM 0
Share

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.

avatar image hijinxbassist · Jun 06, 2012 at 10:23 PM 0
Share

@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

1 Reply

· Add your reply
  • Sort: 
avatar image
-1

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 :)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hijinxbassist · Jun 06, 2012 at 10:26 PM 0
Share

@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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges