- Home /
Raycasting an empty object
Hi! I'm making a simulator with a 3D cockpit and I need to make use of "hotspots" in order to operate the panel's switches. The artist has created an empty node in the model while I, using an initialization script, assign it a box collider during the start phase.
The box collider seems to be well assigned (see the screenshot) but, somehow, the "hotspot" doesn't get detected by the raycast. Please, notice that the raycast function is already being used to detect the collision with other switches and it's working fine. Do you have any ideas on how can I solve this?
Thanks in advance!
Answer by Statement · Mar 11, 2011 at 05:08 PM
Id make sure your box isn't a trigger, or if it is, you need to enable raycast with trigger in PhysicsManager. Is your cockpit equipped with a collider that might block the raycast? If so, you might want to either get rid of it, or move the hotspot, or set a different layer mask that you then perform raycast against. I can't think of anything else that should be set for this to work.
You can also debug what your raycast is hitting by obtaining the hit objects name and present it in a GUI.Label. Maybe you're hitting something you didn't expect at first?
That box looks a bit 'off' from the switch, and small. Do what Statement said. I would think you do want it to be trigger though. $$anonymous$$ake sure it's in a good layer, not one that ignores rays. Are you using Physics.Raycast or Collider.Raycast? Debug.Log can also be your friend.
Thanks for your reply! I was making a very silly mistake, but now everything's working O$$anonymous$$!
@DaveA: Sorry, I hadn't seen your reply before posting $$anonymous$$e! The hotspot is now working. I assigned it just a collider, I didn't need to set it as a trigger.
Your answer
Follow this Question
Related Questions
Ray Casting - Trigger function 1 Answer
Get object name from raycast. 1 Answer
Need help with building system 1 Answer
How to store player model and then swap the model to an object I Raycast hit? 0 Answers
Creating a teleportation gun 1 Answer