用户:
帝过杀马查看:4 回复:4 评论:4 创建时间:2021-05-18T13:35:30
请问在box3中,怎样设置玩家的出生点?
知道的回我,急需!谢谢!
希望哪位大佬帮帮我!!!
爱探险的可乐呀这个很简单啊 吉吉喵发过帖子 代码是:world.onPlayerJoin(({entity})=>{/*监听当玩家进入时*/entity.position.set(3,8,125);/*出生点设置成x:3,y:8,z:125,也可以自定义*/entity.player.spawnPoint.copy(entity.position);/*玩家的重生点(掉下之后的复活点、forceRespawn时的复活点)复制成玩家的位置(x:3,y:8,z:125),也可以自定义*/});
点赞1
评论
AB骉Alobokfor (const e of world.querySelectorAll('*')) {
e.collides = true //实体可以被碰撞
e.fixed = true //实体固定位置
e.onEntityContact(({ other }) => {
if (other.isPlayer) { // 如果跟当前实体碰撞的是玩家实体
e.destroy() //当前实体消失
other.player.invisible = true // 玩家皮肤隐藏
other.mesh = e.mesh // 玩家的外形换成当前实体的外形
other.meshScale.copy(e.meshScale) // 玩家外形的缩放比例设成跟当前实体一样
other.player.scale = e.meshScale.scale(e.bounds.y / other.bounds.y) //喵家的隐形碰撞盒缩放到模型刚好贴地
}
})
}
https://www.bilibili.com/video/BV1g64y1S768
在某个坐标出生的4种写法:
world.onPlayerJoin(({entity})=>{
entity.player.spawnPoint.set(4, 11, 4)
entity.player.forceRespawn()
})
world.onPlayerJoin(({entity})=>{
entity.player.spawnPoint.set(4, 11, 4)
entity.position.copy(entity.player.spawnPoint)
})
world.onPlayerJoin(({entity})=>{
entity.player.spawnPoint = new Box3Vector3(4, 11, 4)
entity.player.forceRespawn()
})
world.onPlayerJoin(({entity})=>{
entity.player.spawnPoint = new Box3Vector3(4, 11, 4)
entity.position.copy(entity.player.spawnPoint)
})
在某个模型的位置出生:
world.onPlayerJoin(({entity})=>{
entity.player.spawnPoint = world.querySelector('#出生点').position
entity.position.copy(entity.player.spawnPoint)
entity.position.y += 10
})点赞0
评论