尽管我尝试了几乎所有解决方案,但我的装备总是不断滞后 [英] My rig is always constantly lagging even though I tried almost every solution

查看:63
本文介绍了尽管我尝试了几乎所有解决方案,但我的装备总是不断滞后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL;底部的DR

晚上好/下午好/早上好,我正在尝试创建一个简单的迷宫恐怖游戏,现在我正在尝试编写我的敌人的代码.我用这个装备尝试制作我自己的自定义敌人,

解决方案

尝试删除 repeat until 循环,因为 distance 变量似乎没有在代码.

代码结构如下:
变量定义
开始while循环
循环播放器
if 语句检查玩家距离 <可选的.如果你这样做,你需要一个变量来让 NPC 跟随玩家的最大距离.此变量应在变量定义"部分中创建
:CreatePath() 和 :ComputeAsync()
循环结束
:GetWaypoints()
开始新的 for 循环以遍历航点
:MoveTo(.Position)
:MoveToFinished:Wait(0.1) <强烈推荐.这为脚本提供了足够的时间来创建和计算另一个路径
循环结束
if 语句结束
结束while循环

如果您有任何问题,请告诉我

TL;DR at the bottom

Good evening/afternoon/morning, I am trying to create a simple maze-horror game, and right now I'm trying to code my enemy. I used this rig to try to make my own custom enemy, https://www.roblox.com/library/5025299499/R15-Character-Template

I am using pathfinder to make my NPC chase the enemy which is working perfectly, except for the fact that it's constantly glitching/lagging. I tried every way possible, from refusing to use "humanoid.MoveToFinished", and using the code below instead. I also tried making the HumaoidRootPart be set to, "SetNetworkOwner(nil)". The only thing I haven't tried is to set ALL my parts in the rig too, "SetNerworkOwner(nil)", but I have NO idea on how to do that. I tried looping through all the parts, but I dont even know how to set each part that I looped through to, "SetNetworkOwner(nil). I also made and added custom parts into each body part of the rig, as you can see from the picture below. Please help me out, I really appreciate it.

TL;DR: I created an enemy using a template, I successfully used pathfinder, but it's just always lagging, even with all my efforts to stop the lag.

解决方案

Try deleting the repeat until loop as the distance variable doesn't seem to be used in the code.

Here would be the code structure:
Variable defining
Begin while loop
Player for loop
if statement to check player distance < optional. If you do this, you need a variable for max distance for the NPC to follow a player. This variable should be made in the 'Variable defining' section
:CreatePath() and :ComputeAsync()
end for loop
:GetWaypoints()
start new for loop to loop through waypoints
<Humanoid>:MoveTo(<v>.Position)
<Humanoid>:MoveToFinished:Wait(0.1) < Highly recommended. This gives the script enough time to create and compute another path
end for loop
end if statement
end while loop

Please let me know if you have any questions

这篇关于尽管我尝试了几乎所有解决方案,但我的装备总是不断滞后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆