用户:
DebugDynamo查看:2 回复:4 评论:2 创建时间:2022-07-18T21:46:40
今天弄一个神奇的东西——骨龙喵()
会的捧个场,不会的也捧个场()()
首先开启玩家的伤害()
world.onPlayerJoin(async/*我也不知道为什么要加()这是我的习惯()*/({entity})=>{
entity.enableDamage = true //开启伤害
})
然后定义一个玩家属性(一会会用到)()
world.onPlayerJoin(async/*我也不知道为什么要加()这是我的习惯()*/({entity})=>{
entity.enableDamage = true //开启伤害
entity.texiao = ''
})
接着弄一个神奇的代码,让特效跟着玩家走()()
world.onPlayerJoin(async/*我也不知道为什么要加()这是我的习惯()*/({entity})=>{
entity.enableDamage = true //开启伤害
entity.texiao = ''
setInterval(() => {
if (entity.texiao/*检测玩家有没有开启特效*/) {
entity.texiao.position = new Box3Vector3(entity.position.x, entity.position.y - 1, entity.position.z)
}
}, 1)
})
再加个旋转()()
world.onPlayerJoin(async/*我也不知道为什么要加()这是我的习惯()*/({entity})=>{
entity.enableDamage = true //开启伤害
entity.texiao = ''
setInterval(() => {
if (entity.texiao/*检测玩家有没有开启特效*/) {
entity.texiao.position = new Box3Vector3(entity.position.x, entity.position.y - 1, entity.position.z)
entity.texiao.meshOrientation.copy(entity.texiao.meshOrientation.rotateY(Math.PI / 40))
}
}, 1)
})
接下来我们放一个圆形的模型()()
我这里用的是一个叫光环的模型()
然后写一下按下左键开启特效的代码()
world.onPress(async/*又来了……*/({button,entity})=>{
if(button==Box3ButtonType.ACTION0/*检测玩家是否按下左键*/){
entity.texiao = world.createEntity({ mesh: "mesh/光环.vb", meshScale: new Box3Vector3(1, 1, 1), collides: false, gravity: false })//创建模型
entity.texiao.addTag('特效')//一会用于添加伤害,不想要伤害的自己去掉(
entity.texiao.id = entity.player.name //也是为了伤害()
}
})
松开左键自动关闭特效的代码:
world.onRelease(async/*……………………*/({button,entity})=>{
if(button == Box3ButtonType.ACTION0){
entity.texiao.removeTag('特效')//特效开始清除
entity.texiao.destroy()
entity.texiao = '' //特效清除完成
}
})
完整代码如下:
world.onPlayerJoin(async/*我也不知道为什么要加()这是我的习惯()*/({entity})=>{
entity.enableDamage = true //开启伤害
entity.texiao = ''
setInterval(() => {
if (entity.texiao/*检测玩家有没有开启特效*/) {
entity.texiao.position = new Box3Vector3(entity.position.x, entity.position.y - 1, entity.position.z)
entity.texiao.meshOrientation.copy(entity.texiao.meshOrientation.rotateY(Math.PI / 40))
}
}, 1)
})
world.onPress(async/*又来了……*/({button,entity})=>{
if(button==Box3ButtonType.ACTION0/*检测玩家是否按下左键*/){
entity.texiao = world.createEntity({ mesh: "mesh/光环.vb", meshScale: new Box3Vector3(1, 1, 1), collides: false, gravity: false })//创建模型
entity.texiao.addTag('特效')//一会用于添加伤害,不想要伤害的自己去掉(
entity.texiao.id = entity.player.name //也是为了伤害()
}
})
world.onRelease(async/*……………………*/({button,entity})=>{
if(button == Box3ButtonType.ACTION0){
entity.texiao.removeTag('特效')//特效开始清除
entity.texiao.destroy()
entity.texiao = '' //特效清除完成
}
})
排版不要没!!!!!!
这是刚出炉的代码,有什么BUG评论区反馈
DebugDynamo伤害代码(新)
//用于区别释放特效的人
global.find = n => global.world.querySelectorAll('player').find(ns => ns.player.name == n)
//以下为伤害代码,借鉴了Stephan轩的激光特效的伤害()
world.onTick(({ entity, tick }) => {
if (tick % 2 === 0) { //每两个tick检测一次
world.querySelectorAll('.特效').forEach(async (jiguang) => { //获取所有单节激光实体
jiguang.point = { //更新激光伤害区域 //你可以根据你的模型调整范围
lo: new Box3Vector3(jiguang.position.x - 15, jiguang.position.y - 1, jiguang.position.z - 15), //最低坐标
hi: new Box3Vector3(jiguang.position.x + 15, jiguang.position.y + 2, jiguang.position.z + 15), //最高坐标
}
for (const e of world.searchBox(jiguang.point)) { //获取伤害区域内的所有实体
if (e == find(jiguang.id)) continue
e.hurt(15,{
attacker:find(jiguang.id)
})
}
})
}
})点赞0
评论