Ship Functions Reference

Note

Delete any methods you’re not using in your script. Calling methods has overheads which can be removed if they don’t exist, meaning the game won’t attempt to call them.

Global Scope

Any code written in the global scope (outside of functions) will be ran, so you can use the top of the script to initialize data.

Start()

Called once after the script has been initialized by the game. By this point, the ship has been intialized and is ready to go.

Update(unscaledDeltaTime, deltaTime)

Called once per rendered frame.

unscaledDeltaTime: How much time there was between the last frame and the current one.

deltaTime: How much time there was between the last frame and the current one, scaled by the game’s timescale. This will be zero when the game is paused.

FixedUpdate(deltaTime)

Called once per physics tick, which is 200 times a second. You can use this to add custom physics behaviours to ships.

deltaTime: The tick rate of the physics.

OnDestroy()

Called when the ship is destroyed. You likely don’t need to use this, but can be used to cleanup resources if any were created via script which won’t be cleared out by Unity automatically.

OnShipAbsorb(shieldRestored)

Called when the ship absorbs a pickup.

pickup: The amount of shield energy that was restored.

OnShipPickup(pickup)

Called when the ship has obtained a new pickup.

pickup: The pickup that was obtained.

OnShipDrop(pickup)

Called when the ship has dropped a pickup.

pickup: The pickup dropped.

OnShipUse(pickup)

Called when the ship has used a pickup.

pickup: The pickup used.

OnShipExploded()

Called when the ship has just been eliminated. If respawning is enabled, OnShipRespawn() will be called shortly after this.

OnShipRespawn()

Called when the ship has just been respawned.

OnShipTeleported(oldPos, oldRot)

Called when the ship has just been teleported through a portal.

oldPos: Vector3 holding the ships position before the teleport. oldRot: Quaternion holding the ships rotation before the teleport.

OnShipFinished()

Callled when the ship has finished the current event.

OnShipHitSpeedPad(pad)

Called when the ship has flew over a 3d speed pad.

OnShipHitSpeedTile(tile)

Called when the ship has flew over a speed tile.

OnShipHitWeaponPad(pad)

Called when the ship has flew over an active 3d weapon pad.

OnShipHitWeaponTile(tile)

Called when the ship has flew over an active weapon tile.

OnShipLapUpdate()

Called when the ship has completed a lap.

OnStartLineTriggered()

Called when the ship has passed the tracks start line.

OnMidlineTriggered()

Called when the ship has passed the tracks mid line (lap validation)

OnShipScoreChanged(oldScore, newScore)

Called when the ships gamemode score has changed.

oldscore: The ships score before the score change. newscore: The ships score after the score change.

OnShipBarrelRolled(success)

Called when the ship has barrel rolled.

success: Whether the barrel roll was succesful.

OnShipHitWeapon(weapon)

Called when the ship has collided with a weapon.

weapon: The weapon that was hit.

OnCountdownStart()

Called when the race countdown has started.

OnCountdownEnd()

Called when the race coundown has ended.

OnCountdownTriggered(stage)

Called when a new stage of the race countdown has started.

stage: The new stage the countdown is at. (3, 2, 1)

OnVirtualPaletteUpdated()

Called when the virtual color palette has updated, in Survival for instance. You can access the current palette settings using VirtualPaletteSettings:CurrentColors.