-
Notifications
You must be signed in to change notification settings - Fork 9
Projectile Entities
Projectiles allow entities to do damage from range. This range is determined by its target location.
Projectiles are created utilizing the ProjectileFactory which Creates a projectile entity using a target vector and shooter entity. The target vector is the location where the bullet will be fired to, despawning upon arrival. This is done utilizing a movement task where the destination is set using the target vector. The stats for the bullet are pulled from the shooter entities config so the damage scales with the shooter's damage. The projectile entity is created and has a physicsComponent, PhysicsMovementComponent, HitboxComponent, ProjectileAttackComponent, combatStatsComponent, AiComponent and EnemyAnimationComponent . The projectile attack component is created so the projectile will explode on contact with players, walls, structures and non ranged enemies.
After creation, the projectile can be spawned using the entity placement service.
Example code of creating bullet and spawning in at a certain location:
This tasks assigns the projectile entity to move in a straight line, it updates movement similar to the chase task without the retargeting.
If the projectile misses the target it will eventually dispose itself when it reaches the initial destination.
This component acts similar to the TouchAttackComponent except projectile behaviour is added. The differeince in behaviour is a simple dispose() added to after the entity touches the target -> Hits the target (deals damage) -> Disposes(with animation triggers)
- lower the redundancy of the Code, since the TouchAttack and ProjectileAttack is very similar, possibly merging the code and adding conditional logic to determine if it's a bullet or not may be required.
- Sprint 1 only had enemies shooting projectiles which meant task setups to shoot the projectile were coded just for enemies (Check enemies feature tasks), for other entities like turrets and guns(Player weapons) new tasks may be required to shoot depending on the method of triggering the projectile.
Escape Earth Game
Interaction Controller and Interactable Components
Game and Entity Configuration Files
Loading Game Configuration Files