1
votes

I am currently having trouble with my enemy AI Script. I am currently new to Unity, so I am still learning a lot, but when my player moves and my enemy follows the player, The enemy starts to jitter and I have yet to find a solution to this tiny problem.

Here are the things I've tried out:

  • I have Cinemachine attached to my player camera follow so I thought it might be that so I changed the Update method and BlendUpdate method to SmartUpdate and LateUpdate.

  • I tried interpolating the Rigidbody 2d on my enemy character, but it did nothing.

  • I tried coding the smoothing, (changed update to fixedupdate on Vector2.MoveTowards).

  • I tried searching for multiple different tutorials and tried all of them.

  • I looked at forums on the internet but they had outdated answers or no answer, or it was the wrong game engine.

I've been stuck on this problem for 2 weeks already and I feel like I can't move forward with development if I haven't figured this out. I removed my enemy follow script for now. I read in one of the forums that they may be animating on two different clocks, which I understand yet don't understand how to fix, so please do help!

1
Hi and welcome to StackOverflow! Please try to create a minimum code example and link it in your question. Also please take a look at the how-to-ask guide for tips on question asking: stackoverflow.com/help/how-to-ask - Zion Perez

1 Answers

0
votes

Looks like I figured it out! instead of interpolating the Rigidbody2D on the enemy, I had to Interpolate the Rigidbody2D on the Player and now it's not jittering anymore :D