Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Update Problem with Function inside Update()

$
0
0
I want my character to look at the enemy: function UpdateSmoothedMovementDirection(){ ... var forward = lockOnTarget.TransformDirection(Vector3.forward); ... } Update(){ function 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.

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>