用户:帅气的剑杰查看:267 回复:7 评论:25 创建时间:2020-08-20T15:31:40
如题,碰到模型就能够飞起来的代码求助!!!!
SKQAworld.querySelectorAll('.XX').forEach((e)=>{ //选中所有标签为XX的模型
e.onEntityContact(({entity,other})=>{ //设置碰撞事件
if(!other.isPlayer){return} //防止非玩家实体参与检测
other.canFly=true; //玩家飞行
});
});点赞0
评论
谢谢啊
为什么飞不了?
你的模型有标签吗,把标签名替换到XX上(不用我说了吧)
看上面
漏了个player
world.querySelectorAll('.啊哈哈').forEach((e)=>{ //选中所有标签为XX的模型
e.onEntityContact(({entity,other})=>{ //设置碰撞事件
if(!other.isPlayer){return} //防止非玩家实体参与检测
world.say('恭喜找到彩蛋!')
other.canFly=true; //玩家飞行
});
});点赞0
评论
我移过去就是这样的
消息都发了,还不能飞行
不懂
把other.canFly=true改成other.player.canFly=true;
额,漏了player……
呃,原来i也会.....
额,咋碰到模型私信.......
world.querySelectorAll('.狗头').forEach((e)=>{ //选中所有标签为XX的模型
e.onEntityContact(({entity,other})=>{ //设置碰撞事件
if(!other.isPlayer){return} //防止非玩家实体参与检测
world.say(entity.player.name+'复原成功!')
});
});点赞0
评论
额,不能用entity.player.name吗?................
不能……因为这里你设置的是e.onEntityContact(({前entity后other!!!}) 前面是指要设置碰撞事件的实体(也就是“狗头”模型),后面是被设置碰撞事件的实体(也就是玩家),你如果用entity(“狗头”模型).player.name,也就是“狗头”模型的名字,服务器咋整……(代码小佬在线教学doge)
如果你要私信的话,把world.say(全局消息)改成other(是玩家不是狗头模型我跟你说过了).player.directMessage就行了
括号比较多,自行把括号里的中文注释删了吧……
嗯,谢谢大佬教学嘿嘿【doge】