- Home /
Selecting gameobjects in game,
Hey! Need help with a script, the thing is that i want to be able to click a gameobject, in game and i want it to get highlighted, and set som kind of variable. Final result is that i can click a character and be able to walk around with that one instead of the main character. How to?
Cheers!
Answer by · Oct 07, 2010 at 10:20 PM
Take a look at this object selection snippet for a start. You could 'highlight' the object by changing its material, and you should know how to set variables (if you don't, you should work through some tutorials to learn unity fast).
For switching control between characters, I would probably have the same 'player' script on both, and when you click on a new 'player', disable the current 'player' script and enable the 'player' script on the newly-selected character. You'll need to use GetComponent to find the script instance, and then set the script instance '.enabled' to true/false accordingly.
This should get you started. If you haven't already worked through some tutorials, I would strongly recommend you do so before attempting any substantial project.
Answer by matyicsapo · Oct 07, 2010 at 08:20 PM
http://unity3d.com/support/resources/example-projects/procedural-examples In one scene you can paint on the surface of a sphere and in an other you can grab the endpoints of the lightning bolts around. Checking the corresponding scripts should get you started I presume.
Your answer
![](https://koobas.hobune.stream/wayback/20220613075030im_/https://answers.unity.com/themes/thub/images/avi.jpg)