用户:
治愈绾兮查看:3 回复:13 评论:3 创建时间:2021-08-22T16:59:04
上一次我发了初级版直线末影珍珠代码,这一次变成了像起床中抛物线版的。
执行此代码需要在文件中有一个叫末影珍珠的模型
world.onPlayerJoin(({ entity }) => {
entity.player.onPress(async ({ button, raycast}) => {
if (button !== 'action1') {
return;
}
const e = world.createEntity({
mesh: 'mesh/末影珍珠.vb'
});
const chaoxiang = entity.player.facingDirection
world.say(chaoxiang)
e.position.copy(entity.position)
e.velocity = chaoxiang.scale(2)
e.velocity.y = raycast.direction.y * 2;
e.onVoxelContact(({ x, y, z }) => {
entity.position.set(x, y + 2, z)
e.destroy()
})
e.onEntityContact(() => {
entity.position.copy(e.position)
e.destroy()
})
})
})world.onPlayerJoin(({ entity }) => {
entity.player.onPress(async ({ button, raycast}) => {
if (button !== 'action1') {//如果不是右键
return;//退出(群聊)
}
//如果是右键,扔出实体
const e = world.createEntity({
mesh: 'mesh/末影珍珠.vb'
});
const chaoxiang = entity.player.facingDirection
world.say(chaoxiang)
e.position.copy(entity.position)
e.velocity = chaoxiang.scale(2)
e.velocity.y = raycast.direction.y * 2;
e.onVoxelContact(({ x, y, z }) => {
entity.position.set(x, y + 2, z)//玩家传送过去
e.destroy()//删除实体
})
e.onEntityContact(() => {
entity.position.copy(e.position)
e.destroy()
})
})
})点赞0
评论