- Home /
Look at object when it is in the range of the player
hey guys,
I am looking for a C#script that helps me to make my player look at an object when it is in a specific range and hitting a button.
so basically should nearly every gameobject be the target but the player should look while he is hitting shift at the nearest one
i tried something like
public Transform myCurrentTarget; // reference a target you want to aim/look at here.
void AimLookIK ()
{
if(!myCurrentTarget) return;
Vector3 targetPos = myCurrentTarget.position;
a.SetLookAtPosition (targetPos);
a.SetLookAtWeight(1, 0.5f, 0.7f, 0.0f, 0.5f);
}
but i think thats horribly wrong. would be nice if someone could help me out with that :)
Comment
Your answer
Follow this Question
Related Questions
Quick C# Question - Variables in Other Scripts 2 Answers
Distribute terrain in zones 3 Answers
look at closer 1 Answer
lookAt on Y axis only 1 Answer
Multiple Cars not working 1 Answer