|
i have a hovertank thing with rockets and guns and missiles and i have them all shooting at a target (a cube) i want the target to change to whatever object i click on, does anyone know how to do this? i don't want to have to put a script on every object and then send a message because i will have heaps of things.
(comments are locked)
|
thankyou lots!
Dec 27 '11 at 09:53 AM
sam32x
(comments are locked)
|
|
I would use the unity function OnMouseDown and then change a select variable you can have in a master GUI script.
(comments are locked)
|
|
Search for mouse raycasting, you'll find what you need. The idea is to convert the 2d cursor position in 3d, raycast, and then hit.transform gives you the transform of the object you are pointing. Plenty of examples already out there!
(comments are locked)
|

i mean like a line of code that says something like