- Home /
Question by
RickyX · Mar 06, 2014 at 08:00 PM ·
transform.lookat
Upper body look at problem
Well when i use transform.LookAt it works, but when i use something like UpperBody.LookAt it doesen't work, why ? What's the other way to make Upper Body look at some object ?
Comment
Don't understand what this UpperBody is. Is it some gameobject? You can use LookAt method on gameobject's transform. Try UpperBody.transform.LookAt().
UpperBody is set-up transform of the characters torso. So i don't need .transform for it becouse it's set up as transform already. But when i do LookAt on it, it doesn't work, nothing happens. It's a bone anyway, if i can call it like that.
Answer by Gooey-Man · Mar 07, 2014 at 01:38 AM
Try this:
// This complete script can be attached to a camera to make it
// continuously point at another object.
// The target variable shows up as a property in the inspector.
// Drag another object onto it to make the camera look at it.
var target : Transform;
// Rotate the camera every frame so it keeps looking at the target
function Update() {
transform.LookAt(target);
}
Make the Target your upper body. This script does not have to be used with a camera.
Your answer
![](https://koobas.hobune.stream/wayback/20220613135544im_/https://answers.unity.com/themes/thub/images/avi.jpg)