• 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
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

People who like this

0 Show 0
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
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
rutter

People who like this

1 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!

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Raycast can't detect objects on layermask 1 Answer

Help Can't find the Correct Parameters 1 Answer

Move up gameobject from under the ground or object (vibration problem) 0 Answers

How do I use layermasks? 9 Answers

Raycast Layermask doesn't ignore no layered Parent? 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