var target : Transform;
if(Input.GetKeyDown(“u”)) {
target = (“i want to select a gameObject”)
}
how can i do this ?
var target : Transform;
if(Input.GetKeyDown(“u”)) {
target = (“i want to select a gameObject”)
}
how can i do this ?
try this
var target : Transform;
if(Input.GetKeyDown("u")) {
target = GameObject.Find("Obj Name").transform;
}
PLEASE give more information… or at least format the code, your title doesn’t tell me anything just that its about Game Objects and the transform component, your code is the only thing telling me what you want.
please read the tutorial on writing question to help you get the best chance of good answers.
anyway im assuming you want to assign a transform when the key “u” is pressed.
var target : Transform;
function Update() {
if(Input.GetKeyDown("u")) {
print("I want to select a GameObject");
target = GameObject.Find("MyGameObejct").transform;
}
}
you should check out/revise some Javascript/Unity tutorials if you’re struggling with that one. what is it for?