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.
because you need to press that button "LockOn" !!! if if you don't press it it makes lockon false witch means as soon as you release that button it will make LockOn bool false witch means it will now go through if(lockOn){ var forward = lockOnTarget.TransformDirection(Vector3.forward); } but it'll skip it because lockOn is false
– sdgd