rocket-launchRocket Launch

Description

RocketLauncher is a component responsible for detecting targets, visually highlighting enemies, and sequentially launching rockets at available player targets.

The class manages targeting logic, interacts with the HUD, rocket configuration, and player context, and coordinates the asynchronous launch of multiple rockets.


To work with the rocket system, please refer to the following classes:

  • RocketLauncher.cs (path: Scripts/Runtime/Logic/Player/RocketLauncher.cs)

  • RocketLauncherUI.cs (path: Scripts/Runtime/UI/HUD/RocketLauncherUI.cs)


RocketLauncher Class

RocketLauncher is a Unity component that controls the player’s homing missile system. The component provides the following functionality:

  • Initializes rockets and required dependencies

  • Periodically scans the area around the player to detect visible, alive enemies within a specified radius

  • Highlights detected enemies in the HUD as valid targets

  • Distributes detected targets among available rockets

  • Resets target focus during the reload process

  • Upon receiving a command from the HUD, asynchronously launches rockets with a small delay between launches, directing each rocket toward its assigned target

Scene setup: The component is attached to the Rocket object inside the PlayerContext.

Code access: A reference to the RocketLauncher is registered in PlayerGraphicsContext.


RocketLauncherUI Class

RocketLauncherUI is a UI component responsible for controlling the missile launcher user interface:

  • Handles the rocket launch button input

  • Starts the reload process, disables the launch button, and displays a reload timer

Scene setup: The component is attached to the HUD/Holder/RocketLauncher object. All required references are preconfigured in the component to ensure correct operation.

RocketLauncher Prefab Structure

RocketLauncher prefabs can be found at: StaticAssets/Prefabs/Rocket/...

The prefab consists of two main entities:

  • The visual rocket launcher holder (RocketLauncher)

  • A set of rockets nested inside the holder (the RocketContext prefab)

Physics Interaction and Player Destruction

The visual RocketLauncher object:

  • Contains a Rigidbody and a BoxCollider

  • Is assigned to the PlayerPart layer

  • Participates in the Player Explosion system

After the player is destroyed, the rocket launcher:

  • Detaches from the player

  • Responds to physics

  • Is thrown away, preserving visual consistency in the scene

More detailed information can be found here.

RocketContext Structure

Each rocket is represented by a separate RocketContext, which includes:

  • A rocket visual model

  • Particle effects (smoke, fire, explosion)

  • Trail effects

  • An audio manager

The RocketLauncher manages logic only — all visual and audio effects are encapsulated within the RocketContext.

Last updated