用户:
卫道士32_32*2没了查看:5 回复:2 评论:5 创建时间:2021-02-11T18:28:31
sp=async(hitPosition,e) => {
console.log(e.id)
var direction = hitPosition.sub(e.position);
var orientation = Quat.rotateY(Math.atan2(direction.z, direction.x))
var orientation2 = Quat2.rotateY(Math.atan2(direction.z, direction.x))
e.meshOrientation.copy(orientation)
var crted = world.createEntity();
crted.ctrl = false;
crted.meshOrientation.copy(orientation2);
crted.position.set(e.position.x, e.position.y, e.position.z);
crted.mesh = roc.mesh;
crted.meshScale = roc.meshScale;
crted.gravity = false; crted.fixed = false;
crted.launcher = e;
crted.addTag("lchr");
crted.mass = 1;
crted.onEntityContact(({other})=>{
try{other.player.forceRespawn()}catch{}
})
crted.particleLimit = 1000;
crted.particleRate = 1000;
crted.particleColor = [new Box3RGBColor(1, 1, 0), new Box3RGBColor(1, 0, 0)]
crted.particleSize = [5, 4]
crted.particleAcceleration.set(0, -5, 0)
crted.particleVelocitySpread.set(5, 1, 5);
crted.particleLifetime = 2;
crted.gravity = false;
for (let i = 0; i < 10; i++) {
crted.velocity.x += direction.x / 100;
crted.velocity.y += direction.y / 102;
crted.velocity.z += direction.z / 100;
await sleep(30);
}
crted.tar = hitPosition;
crted.ctrl = true;
setTimeout(() => { crted.destroy() }, flyTime*1000)
}
world.onVoxelContact(async ({ entity, x, y, z }) => {
if (entity.hasTag("lchr")) {
entity.particleVelocity.set(0, 30, 0);
await sleep(500);
entity.destroy()
}
})