x


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

more ▼

asked Nov 09 '11 at 11:48 AM

mehowe7 gravatar image

mehowe7
31 15 15 17

(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

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.

more ▼

answered Nov 10 '11 at 12:18 AM

dannyskim gravatar image

dannyskim
3.9k 5 7 19

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2083
x1528
x983
x225
x151

asked: Nov 09 '11 at 11:48 AM

Seen: 1014 times

Last Updated: Nov 10 '11 at 12:18 AM