I want my character to look at the enemy:
function UpdateSmoothedMovementDirection(){
...
var forward = lockOnTarget.TransformDirection(Vector3.forward);
...
}
Update(){
UpdateSmoothedMovementDirection();
if(Input.GetButton("LockOn")){
lockOn = true;
}
else{
lockOn = false;
}
It works very well this way, but when i put it this way:
(inside the UpdatedSmootedMovementDirection())
if(lockOn){
var forward = lockOnTarget.TransformDirection(Vector3.forward);
}
It doesn’t update it every frame like the first one. I have to pull my finger and press the button every time i want to update the direction of my character faces.