Convert a GameObject to a transform?

What i need to do is find a GameObject with findtag; in the scene and convert it to a transform so i can use

`transform.LookAt(target);`

If there is another way of doing this that would also be great! Thanks Guys!
I cant seem to wrap my head around it yet.

#pragma strict //If you want to change tag in inspector. MainCamera is default just for this example. var targetTag : String = "MainCamera"; private var target : Transform; function Start() { //Use GameObject.FindWithTag as usual, then reference the GameObject's Transform component. target = GameObject.FindWithTag(targetTag).transform; print(target.name); }

–

1 Answer

1

If the target in your code is the GameObject just use this:
transform.LookAt(target.transform);

omg... so simple. haha i hate that. Thanks Man. I was about to falcon punch my computer.

–