AirdropMarker
Updated a year agoAirdropMarker
This documentation provides an explanation of the code for the AirdropMarker
class. The AirdropMarker
class is responsible for spawning and controlling an airdrop vehicle in a virtual reality game environment.
Class Structure
The AirdropMarker
class is a MonoBehaviour
that inherits from the Unity class MonoBehaviour
. It is defined within the AndrewFTW
namespace.
Public Fields
The class has the following public fields:
DropVehicle (GameObject)
: A reference to theGameObject
representing the airdrop vehicle.WaitToSpawn (float)
: The time to wait before spawning the airdrop.SpawnAltitude (float)
: The altitude at which the airdrop vehicle will be spawned.SpawnRadius (float)
: The radius around the airdrop marker within which the airdrop vehicle will be spawned.TravelSpeed (float)
: The speed at which the airdrop vehicle will travel.ZeroingOffset (float)
: An offset value used for fine-tuning the position at which the payload is dropped.DropPrefabs (GameObject[])
: An array ofGameObject
s representing the payloads that can be dropped.DropSpeedInheritPercent (float)
: The percentage of the airdrop vehicle's velocity that will be inherited by the dropped payloads.DropSpawnOffset (float)
: The offset distance from the airdrop vehicle's position at which the payloads will be spawned.DoesRequireSkySight (bool)
: A flag indicating whether line of sight is required for the airdrop to occur.IsDestructable (bool)
: A flag indicating whether the airdrop vehicle is destructible.LMVehicleCrashLayers (LayerMask)
: The layer mask used for checking collision with the airdrop vehicle.
Methods
The class has the following methods:
Start()
This method is called when the script instance is being loaded. It initializes the airdrop vehicle and performs the necessary setup.
- It sets the rotation of the marker randomly.
- It creates two points:
_vehicleInstPt
for spawning the vehicle and_centerPt
as the center point of travel. - It adjusts the positions of
_vehicleInstPt
and_centerPt
to avoid collisions with other objects. - It instantiates the airdrop vehicle at
_vehicleInstPt
, adjusts its position, and sets it free in the world. - If
DoesRequireSkySight
is enabled, it checks for line of sight and ends the drop if there is an obstruction.
FixedUpdate()
This method is called every fixed frame-rate frame. It moves the airdrop vehicle, spawns the payload, and checks for the end conditions of the airdrop.
- It moves the airdrop vehicle at the specified
TravelSpeed
. - It calculates the distance traveled by the airdrop vehicle.
- If the airdrop vehicle reaches the desired distance from the center, it spawns the payload.
- If the airdrop vehicle moves too far from the center, it ends the airdrop.
- If the airdrop vehicle is marked as destructible and it is destroyed, it ends the airdrop.
EndDrop()
This method ends the airdrop. It destroys the airdrop vehicle and the airdrop marker object.