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 /
This question was closed Jul 08, 2014 at 06:47 PM by pheash for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by pheash · Jun 15, 2012 at 07:52 PM · raycastlayermaskbce0023

Raycasting with LayerMask gives me a bce0023

hello again: I have a problem casting a ray, looking up other bce0023 seem mostly caused by typo erros, but i cannot find what is wrong with the following script. i even tried creating the ray and all the variables inside the case, but it gives me the same error:

Assets/_Weapons/Scripts/PlayerControls.js(80,44): BCE0023: No appropriate version of 'UnityEngine.Physics.Raycast' for the argument list '(UnityEngine.Ray, System.Type, float, int)' was found.

 if(Input.GetMouseButtonUp(0)){
     var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
     var hit = RaycastHit;
     var layerMask = 1 << 8;    //ignoring all but the gui clickable layer
     switch(mouseState){
         case MouseState.select :
             soundPlayer.PlaySound(soundClick,0,0);
         if (Physics.Raycast(ray,hit,Mathf.Infinity,layerMask)) {
                     if(!hit.transform.tag=="Environment"){
                         selected = hit.transform.parent.transform;        //assigning clicked object
                     }
                     else{
                         Instantiate(deselectParticles,hit.point,Quaternion.Identity);
                         selected = null;    //deselecting since we hit environment
                     }
                     UpdateGUI();
         }
             break;

I am always happy if you have a better way of coding this. I am trying to handle all the user input via switch and a mouseState that can change to different actions, depending on what the mouseCursor is.

Comment
Add comment
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

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Eric5h5 · Jun 15, 2012 at 08:15 PM

As the error message says, you're giving it a Ray, Type, float, and int, but if you look at the docs, you see you need a Ray, RaycastHit, float, and int. Writing "var hit = RaycastHit;" assigns a Type to the hit variable, but you don't want to assign anything to it, you just want to declare the type, namely "var hit : RaycastHit".

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 pheash · Jun 15, 2012 at 09:15 PM 0
Share

see i knew i had a typo in there!!! thank you for the quick reply Eric!

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

SphereCast doesn't work with a layerMask 1 Answer

unity raycast layers in Multiplayer 0 Answers

Layer Mask on raycast2d not working? 1 Answer

I have a problem with Layermask Unity2D 0 Answers

layers not ignored by raycast 1 Answer


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