简体   繁体   English

敌人跟随 Unity 2d 抖动?

[英]Enemy Follow Unity 2d Jittering?

I am currently having trouble with my enemy AI Script.我目前遇到了我的敌人 AI 脚本的问题。 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.我目前是 Unity 的新手,所以我还在学习很多东西,但是当我的玩家移动并且我的敌人跟随玩家时,敌人开始抖动,我还没有找到解决这个小问题的方法。

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 .我将Cinemachine连接到我的播放器相机跟随,所以我认为可能是这样,所以我将Update方法和BlendUpdate方法更改为SmartUpdateLateUpdate

  • I tried interpolating the Rigidbody 2d on my enemy character, but it did nothing.我尝试在我的敌人角色上插入 Rigidbody 2d,但它什么也没做。

  • I tried coding the smoothing, (changed update to fixedupdate on Vector2.MoveTowards ).我尝试对平滑进行编码(将fixedupdate上的update更改为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.我已经被这个问题困住了 2 周,如果我没有弄清楚这一点,我觉得我无法继续开发。 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!我在其中一个论坛上读到他们可能在两个不同的时钟上制作动画,我理解但不明白如何修复,所以请帮忙!

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看起来我想通了,而不是在敌人身上插入 Rigidbody2D:我不得不在 Player 上插入 Rigidbody2D,现在它不再抖动了:D

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM