- Home /
click on a game object that script isn't attached to
i have an empty game object which is my script manager and i have one main script. i want various things to happen when i click on different game objects. how do i use a ray cast to detect what object i have clicked on? all of the solutions on here seem to be for if you click on the game object the script is attached to. thank you
Answer by dannyskim · Nov 10, 2011 at 12:18 AM
I suggest you read over the Unity Script Reference some more in regards to Raycasting. You can set the origin of the ray, it doesn't necessarily have to originate from your empty script manager gameobject. From there, you can designate where to cast the ray towards, for example, the mouse position, and if it intersects any colliders along the way.
Your answer
Follow this Question
Related Questions
Clicked object is stored in a variable? 1 Answer
Object Movement via Mouse Click? 3 Answers
Shoot off multiple raycasts from 1 object? 2 Answers
Mouse Click and Spawn object 4 Answers
Texture-based mouseclick detection 1 Answer