#how can i create a script that can fire projectile with custom properties like fireRate, damage etc.
1 messages · Page 1 of 1 (latest)
bump
i think you create a custom entity , that willl act like a bullet
you put projectile compoenent inside its entity file
then in script you can do
entity.getComponent(`minecraft:projectile`)```
and there is a .shoot() method
shoot()? pls send docs
export function shootProjectile(
entity: Entity,
typeId: string,
power: number,
tag?: string
) {
const headLoc = entity.getHeadLocation();
const viewVector = entity.getViewDirection();
const direction = {
x: headLoc.x + viewVector.x,
y: headLoc.y + viewVector.y,
z: headLoc.z + viewVector.z,
};
const vel = {
x: viewVector.x * power,
y: viewVector.y * power,
z: viewVector.z * power,
};
const projectile = entity.dimension.spawnEntity(typeId, direction);
if (tag) projectile.addTag(`${tag}`);
const shotProj = projectile.getComponent(EntityComponentTypes.Projectile);
if (shotProj == undefined) return;
shotProj.owner = entity;
shotProj.shoot(vel);
}
Im curious, why do we need to tag the bullet,m