Heroic Engine
  • Welcome
  • Getting Started
    • Quickstart
    • Example Games
      • Tic Tac Toe
      • Turn based duel
  • Basics
    • Injection Manager
    • Engine Systems
      • Core Systems
        • Events Manager
        • Input Manager
        • Localization Manager
          • LangText component
        • Music Player
        • Sounds Manager
        • Time Manager
        • Scenes Loader
        • Day Time Controller
        • Weather Controller
      • Gameplay Systems
        • Currencies Manager
        • Player Progression Manager
        • Quest Manager
        • Random Events Manager
        • Hittables Manager
        • Dungeon Generator
      • UI Systems
        • UI Controller
        • Countdown Controller
    • Editor Tools
      • Clear Saves
      • Mobile Build Optimizer
      • Create System
      • Icon from Prefab Generator
    • Engine Utilities
      • PoolSystem
      • DataSaver
      • ComponentExtensions
      • MaterialExtensions
      • SpriteUtils
      • SlowUpdate
      • StringUtils
      • TypeUtility
      • MathHelper
      • VectorUtils
      • TransformUtils
      • MeshUtils
    • Useful Components
      • Floating Item
      • Fly Up Text
      • Label Scaler
      • Ragdoll
      • Rotate To Camera
      • Orbital Camera
      • Rotator
      • Texture Mover
      • Hittable
      • Projectile
      • Projectile2D
      • LifetimeObject
      • Spawner
      • Colorized Particles
      • Draggable2D
      • SaveableTransform
    • Useful Attributes
Powered by GitBook
On this page
  • Parameters in inspector
  • Available methods
  1. Basics
  2. Useful Components

Projectile

PreviousHittableNextProjectile2D

Last updated 3 months ago

This component represents automatically moving projectile. This object inflicts damage to Hittable objects of all opposite teams in certain radius after entering into target collider or after certain amount of time.

Projectile can be auto guided to the target and it can chase it. Projectile class is inherited from IPoolableObject, so it can be got from PoolSystem and it automatically returns to pool after explosion.

Parameters in inspector

Velocity – velocity of projectile movement (units per second). 10 by default.

Guiding – is this projectile guided to the target?

Guiding Force – how strong it is guided to the target? 0 = isn't guided, 1 = maximum guidance

Guiding Angle – width of guidance cone, if target is out of this cone, guiding will be stopped

Guiding Max Dist – max distance to target when guiding works

Lifetime – how much time projectile flies before automatical explosion

Damage Min – min damage to hittables

Damage Max – max damage to hittables

Explosion Radius – radius of explosion (1 unit by default)

Explosion Effect – poolable explosion particle effect.

Launch Sound - sound effect which will be played during projectile launch.

Hit Sound - sound effect which will be played during collisions.


Available methods

public void Launch(Transform target, Hittable owner = null)

This method launches projectile from certain owner to the certain target. If owner is not set, this projectile will be neutral (TeamType.None) and will be able to inflict damage both to player team and enemies team.

Example:

public class Player : MonoBehaviour, Hittable
{
    [SerializeField] private Transform muzzle;
    [SerializeField] private Projectile missilePrefab;

    public void Shoot(Hittable targetEnemy)
    {
        Projectile missile = PoolSystem.GetInstanceAtPosition(
            missilePrefab, 
            missilePrefab.GetName(), 
            muzzle.position, 
            muzzle.rotation);
    
        missile.Launch(targetEnemy.transform, this);
    }
}

public void Launch(Vector3 direction, Hittable owner = null)

This method launches projectile from certain owner to the certain direction. If owner is not set, this projectile will be neutral (TeamType.None) and will be able to inflict damage both to player team and enemies team.

Parameters in inspector