#How to make a script that fires multiple projectiles at different angles when used?
1 messages · Page 1 of 1 (latest)
function shoot(player, projectile, forwardOffset, speed, launchPower) {
const { x, y, z } = player.location;
const direction = player.getViewDirection();
const spawnPos = {
x: player.location.x + player.getViewDirection().x * forwardOffset,
y: player.location.y + 1.5,
z: player.location.z + player.getViewDirection().z * forwardOffset,
};
const arrow = player.dimension.spawnEntity(projectile, spawnPos);
const projectileComp = arrow.getComponent("minecraft:projectile");
const velocity = {
x: direction.x * speed,
y: direction.y * speed,
z: direction.z * speed,
}
projectileComp.shoot(velocity, {
uncertainty: 0,
launchPower: launchPower,
owner: player,
});
}
abit late
but just change this to multiple directions
why do player.getViewDirection() twice when u already made a variable for that??
same goes to destructing player location.
and just use player.getHeadLocation()
Yes make another variable which just offsets it