hifi: #21622 Create turret which fires projectiles

For a game. Needed:

A turret system which shoots at player with bullets & effects. System sound behave like:

If enabled = true, will try to shoot at the player if player is within activeDistance units. It rotates to point at the player at the speed rotateSpeed. It begins firing shots at an interval, shootingInterval. If alwaysShoot is false, it waits until it has a clean shot of the player. It plays a one shot audio clip called chargeSound. As soon as chargeSound finishes, plays shotSound clip, rezzes shotParticle effect and rezzes/shoots bullet with bulletVelocity and bulletGravity parameters. Bullet plays flightSound as it whizzes thru the air. If smartBullet is true, it will attempt to follow the player. Bullet has particleEffect called flightParticle which trails behind it. If bullet hits something, it plays hitSound and rezzes hitParticle. When the bullet collides with something, it serializes a JSON object with this information and sends it to the Message system:

bulletUUID - ID of the bullet
turretUUID - ID of turrent
colliderUUID - ID of whatever was struck
bulletDamage - how powerful was it

Entity must have the following settings:

rotateSpeed - How fast does it lerp to point at the player. Example:
(0, 1, 0) Always pointing at player on Y axis
(0.5, 0.5, 0.5) Lerps to player on all axes
(0.5, 0, 0) rotates on X axis only
shootingInterval - float. how frequently does it shoot at the player
enabled - Bool. Whether or not it's actually operating
alwaysShoot - Bool. Is it always shooting or only when has a clean shot
activeDistance - float. Distance will it become active
bulletVelocity - float. How fast will the bullet travel
bulletGravity - vec3 for gravity
bulletDamage - float. How much damage can it inflict
smartBullet - bool. if on, the bullet attempts to follow player
chargingSound - One shot audio clip played while charging to shoot
shotSound - One shot audio clip played when shot is fired
hitSound - One shot audio clip played when shot hits something
flightSound - Looping audio clip played when bullet travels thru air
shotParticle - Particle system entity rezzed when bullet is shot
flightParticle - Particle system entity rezzed with bullet
hitParticle - Particle system entity rezzed when bullet hits something
hitMessage - he name of a function to call on the entity it hits.


turret.fbx - the model of the turret itself.
turretBase.fbx - a model which sits beneath the turret
bullet.fbx - model of projectile
chargeSound.wav - Energy charging up sound
shotSound.wav - Like a gun shooting a bullet
hitSound.wav - Explosion type sound when it hits
flightSound.wav - looping whiz thru air sound
shotParticle.json - Smoke and sparks one shot effect
flightParticle.json - for creating a trail of smoke
hitParticle.json - explosion when it hits something

Comments & Activity

Labels Saved!


Login to bid
Who Amount Done in ...
No bids yet.