Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Enemy animation gets weird when going to set position

$
0
0
I have an enemy AI and works great until the player is gone and the enemy wants to search at the last known location of the player. Please take a minuet to watch the video to really know what the problem is: https://www.youtube.com/watch?v=k7IYzN5Rq0M&feature=youtu.be I know the part at the end where the enemy slides to the point but i don't know how to fix that and make the enemy stop from keeping moving... CODE: IEnumerator searchForPlayer(){ if (didEnemySeePlayer) { yield return new WaitForSeconds(5); lastPlaceDirection = lastPlayerPosition - transform.position; lastPlaceDirection.y = 0; lastPlaceAngle = Vector3.Angle (lastPlaceDirection, transform.forward); transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation (lastPlaceDirection), 0.1f); print ("checks if starting walking"); chaseState = "WALK"; print ("Changed state"); movingProcess (); print ("started walking"); if(Vector3.SqrMagnitude(transform.position - lastPlayerPosition) < 230){ didEnemySeePlayer = false; print ("Changed to false"); enemyIsIdle (); } } } Please write to me if you have any question but please do try and answer mine. TX.

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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