用户:
流浪月球查看:4 回复:4 评论:4 创建时间:2020-07-25T15:21:45
以下是:当玩家进入某个区域就会穿上装备
const area = world.addTrigger({
selector: 'player',
bounds: {
lo: [80, 0, 3],
hi: [80, 6, 5],
},
})
// 需要用 onEnter() 和 onLeave() 触发事件
area.onEnter(({ entity }) => {
world.say('正在通过安检');
});
area.onLeave(({ entity }) => {
// 有玩家离开区域
sleep(5000);
world.say('通过安检');
entity.player.addWearable({
bodyPart: Box3BodyPart.TORSO,//装备穿戴的位置在身上
mesh: 'mesh/宇航背包.vb',//装备是一个叫做“黄喵包”的模型
orientation: new Box3Quaternion(0, 1, 0, 0).rotateY(Math.PI/2),//将模型沿着Y轴旋转90度
scale: new Box3Vector3(1, 1, 1),//模型大小长宽高都缩小0.5倍
offset: new Box3Vector3(0, 0.1, -0.45),//装备的位置,向人背后偏移一些
});
entity.player.addWearable({
bodyPart: Box3BodyPart.HEAD,//装备穿戴的位置在身上
mesh: 'mesh/头盔.vb',//装备是一个叫做“黄喵包”的模型
orientation: new Box3Quaternion(0, 1, 0, 0).rotateY(Math.PI/2),//将模型沿着Y轴旋转90度
scale: new Box3Vector3(0.75 ,0.75, 0.75),//模型大小长宽高都缩小0.5倍
offset: new Box3Vector3(0, 0.5, -0.1),//装备的位置,向人背后偏移一些
});
entity.player.addWearable({
bodyPart: Box3BodyPart.TORSO,//装备穿戴的位置在身上
mesh: 'mesh/宇航服.vb',//装备是一个叫做“黄喵包”的模型
orientation: new Box3Quaternion(0, 1, 0, 0).rotateY(Math.PI/2),//将模型沿着Y轴旋转90度
scale: new Box3Vector3(0.9, 0.9, 0.9),//模型大小长宽高都缩小0.5倍
offset: new Box3Vector3(0, 0, 0),//装备的位置,向人背后偏移一些
});
});