
Lv.1
!!!!!
在 问吉吉猫一个问题 中回复
world.onPlayerJoin(async({entity}) => {
entity.player.onPress(({ entity, button }) => {
if (button == 'action1'){
const bag = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: `背包`,
content: `请问你喵还是剑?`,
options: ['喵', '剑']
})
if (!bag || bag == null) return;
switch (bag.index){
case 0:
entity.wuqi = '喵'
entity.gjl = 80
break;
case 1:
entity.wuqi = '剑'
entity.gjl = 20
break;
default:
}
}
})
})2022-05-05T18:41:48 点赞:0
在 发射一个模型【简陋教程】 中回复
console.clear()
const Quat = new Box3Quaternion(0,0,0,1)
world.onRelease(async ({entity, button, raycast:{direction}}) => {
//每当有按钮被按下
if (button == Box3ButtonType.ACTION0) {
const 喵 = world.createEntity({
mesh:'发射模型',
position:entity.position,
meshScale:new Box3Vector3(0.1, 0.1, 0.1),
collides:false
})
喵.gravity = false
const 喵_orientation = Quat.rotateY(Math.atan2(direction.z, direction.x)).rotateY(-Math.PI / 2).rotateY(-Math.PI / 2)
喵.meshOrientation.copy(喵_orientation)
for(i = 0; i <= 4; i++){
喵.position.x += direction.x
喵.position.z += direction.z
await sleep(200)
}
await sleep(1000)
喵.destroy()
}
})
world.onPlayerJoin(({ entity }) => {
entity.player.addWearable({
bodyPart: Box3BodyPart.RIGHT_HAND,
mesh: '装饰',
orientation: new Box3Quaternion(0, 180, 60, -160).rotateY(Math.PI / 2.5),
scale: new Box3Vector3(1, 1, 1), offset: new Box3Vector3(0, 0.2, 0.6),
})
})2022-05-05T18:54:58 点赞:0
在 有大神能解答吗 中回复
// 先在场景中放置一个名称为 NPC 的实体。
const npc = world.querySelector('#NPC');
npc.enableInteract = true; // 允许进行互动
npc.interactRadius = 16; // 实体的互动范围
npc.interactHint = npc.id; // 互动提示框显示实体的名称
// 玩家与实体进行交互时触发
npc.onInteract(async({entity}) => {
await entity.player.dialog({
type: Box3DialogType.TEXT, // 对话框的类型,TEXT是文本框。
title: npc.id, // 对话框标题为NPC名字,表示正在说话的是NPC
content: `你好,${entity.player.name},很高兴认识你。`,
});
});2022-05-07T20:37:05 点赞:0