- Home /
Using Raycast for RTS game ?
I'm trying to develop a RTS game and i'm stuck at selecting objects. For example i have 4 FPS controllers which cameras are disabled. When i press them a button will appear and i'll be able to activate their camera with this button. I want to ask 2 things at there.
Is "Detecting name with Raycast hit" possible ? Is saving "Name" as string to static variable at MainCamera and using it at somewhere like "Object'sName.GetComponent(Blabla).enabled = true;"
Answer by kacyesp · Aug 27, 2014 at 08:50 PM
It is possible. See the answer to this post: http://answers.unity3d.com/questions/20328/onmousedown-to-return-object-name.html
Answer by Alp-Giray-Savrum · Aug 27, 2014 at 08:54 PM
I was testing it with "String" variable but something happened.
#pragma strict
var name : String;
var selectedObject : GameObject;
function Start () {
selectedObject = GameObject.Find(name.ToString());
selectedObject.GetComponent(identifyYourself).enabled = true;
}
and i got this error
Ambiguous reference 'name': IdentifyObject.name, UnityEngine.Object.name.
Your answer
Follow this Question
Related Questions
String as Variable name 0 Answers
Return name of file only 1 Answer
Get array of name from file in resources 1 Answer
Change the name of a toolbar button by clicking it. How? 1 Answer
Display Movie Name From www Address With A UI Text? 0 Answers