garrys-mod - 通过眼迹了解实体的类型
问题描述
GetEyeTrace 如何知道我面前的实体。我想检查一下,如果 entity == Weapon 然后做任何事情......
不管像下面这样:
if ply:GetEyeTrace().Entity.IsWeapon() then
print("+")
end
但是 IsWeapon() 函数没有。
解决方案
应该是 :IsWeapon()
您还应该真正检查实体是否有效。
local ent = ply:GetEyeTrace().Entity
if(!IsValid(ent)) then return end
if(ent:IsWeapon()) then
print("This is a weapon.")
end
推荐阅读
- c# - 我试图让这个简单的 c# wb service sript 工作
- javascript - AddEventListener 弹出窗口在 IE 11 中不起作用
- python - VSCode如何使用GMT时区
- python - 使用python将HTML文件转换为CSV
- python - python中什么是反转列表的一部分的最快方法?
- owl - Grakn 支持什么类型的推理?
- javascript - 试图等待一个循环
- javascript - 带有小数的Javascript正则表达式整数
- python - 编辑 FASTA:如何使用正则表达式和列表更改 FASTA 的标题,并替换文件
- git - 当你从公共切换到私有后删除你的仓库时,fork 会发生什么?