- Home /
LookAt transform plus a y value
I have an object that I want to look at but its transform is where the bottom of the object is and I want to look at the middle of the object. I have tried adding a vector3 but it's not working. help or a suggestion of a better way of doing it would be appreciated. target is a transform by the way and objectTriggered is a collider.
if(objectTriggered.gameObject.name == "badguy(Clone)") {
target = objectTriggered.gameObject.transform;
target += new Vector3(0.0f, 5.0f ,0.0f);
turret.LookAt(target);
}
Try using Quaternion.LookRotation, i.e.
Vector3 targetDirection = target.transform.position - turrent.transform.position;
Vector3 targetDirection += new Vector3(0f, 5f, 0f);
turret.rotation = Quaternion.LookRotation(targetDirection);
Answer by LazyElephant · Dec 26, 2015 at 11:36 AM
Add an empty game object and make it a child of the object you want to look at. Position it at the right height, and use that as the item you want to look at instead.
I converted your comment to an answer, if you don't $$anonymous$$d. Your solution is the most reliable way.
Your answer
Follow this Question
Related Questions
transform.LookAt overrides rigidbody rotation 0 Answers
LookAt Problem 1 Answer
hoe to rotate a AI as a animation 1 Answer
!Urgent! How to get a sprite to look at another object? 1 Answer
Slower Ladder 2 Answers