用户:
Alcala查看:5 回复:4 评论:5 创建时间:2022-01-16T17:54:43
Rt,如下代码为何不能让火球发射()
其中,“火球”是一个实体
world.onPress(async({button,entity,raycast}) => {
if(button != 'action0' || !entity.isPlayer || entity.player.dead) return;
const ra = raycast;
const d = ra.distance;
const MeshScale = [1 / 16, 1 / 16, 1 / 16];
const hq = world.createEntity({
mesh: 'mesh/火球.vb',
meshScale: MeshScale,
collides: false,
gravity: false,
position: entity.position,
meshEmissive: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222,
});
hq.id = entity.player.name;
const ani = hq.animate([
{position: entity.position,duration: 1},
{position: ra.hitPosition,duration: 0},
]);
ani.playState({
duration: d / 16,
iterations: 1,
direction: Box3AnimationDirection.NORMAL,
});
hq.destroy();
});
Alcala代码打错了,重发一份
console.clear();
world.onPlayerJoin(({entity}) => {
if(!entity.isPlayer) return;
entity.enableDamage = true;
});
world.onPress(async({button,entity,raycast}) => {
if(button != 'action0' || !entity.isPlayer || entity.player.dead) return;
const ra = raycast;
const d = ra.distance;
const MeshScale = [1 / 16, 1 / 16, 1 / 16];
const hq = world.createEntity({
mesh: 'mesh/火球.vb',
meshScale: MeshScale,
collides: false,
gravity: false,
position: entity.position,
meshEmissive: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222,
});
hq.id = entity.player.name;
const ani = hq.animate([
{position: entity.position,duration: 1},
{position: ra.hitPosition,duration: 0},
]);
ani.play({
duration: d / 16,
iterations: 1,
direction: Box3AnimationDirection.NORMAL,
});
hq.destroy();
});点赞0
评论
不知道该叫啥的一只萌新叮叮叮把
const ani = hq.animate([
{position: entity.position,duration: 1},
{position: ra.hitPosition,duration: 0},
]);
改成
const ani = hq.animate([
{position: entity.position,duration: 1},
{position: ra.hitPosition,duration: 0},
],{
duration: d / 16,//多少秒
iterations: 1,//几次
direction: Box3AnimationDirection.NORMAL
});
后面代码不变
点赞0
评论