<aside> <img src="/icons/reorder_gray.svg" alt="/icons/reorder_gray.svg" width="40px" />

Navigation

</aside>

🏠 Home Page

Getting Started

Architecture

Level System

Characters & Vehicles

Run Mechanics

World Objects

Boosters & Modifiers

Progression & Economy

UI

Save & Debugging

Modules

Publishing

Reference

💰 Monetization (Ads & IAP)

<aside> 💡 A new vehicle needs a movement behavior, a VehicleData asset, a visual prefab, a Character prefab and a Character asset.

</aside>

Steps

  1. Create the movement behavior. Inherit from MovementBehavior. TickMovement runs in the physics step while the character is launched. Read the steering from character.MoveValue.

    using UnityEngine;
    
    namespace Watermelon
    {
        public class HoverMovementBehavior : MovementBehavior
        {
            private readonly float turnRate;
    
            public HoverMovementBehavior(float turnRate)
            {
                this.turnRate = turnRate;
            }
    
            public override void OnEnter(PlayerController character)
            {
                // Reset the per-run state here
            }
    
            public override void TickMovement(PlayerController character)
            {
                float turn = character.LimitTurn(character.transform.forward, character.MoveValue.x * turnRate);
    
                Rigidbody rb = character.Rigidbody;
                Quaternion rotation = Quaternion.Euler(0f, turn * Time.fixedDeltaTime, 0f);
    
                // Turn the heading and keep the speed
                rb.velocity = rotation * rb.velocity;
                character.transform.rotation = rotation * character.transform.rotation;
            }
        }
    }
    

    LimitTurn keeps the vehicle from turning back to the start. Use it for every steering value.

  2. Create the VehicleData class. Inherit from VehicleData, expose the tuning values and create the behavior. Apply the efficiency multiplier of the upgrade here.

    using UnityEngine;
    
    namespace Watermelon
    {
        [CreateAssetMenu(fileName = "Hover Vehicle", menuName = "Watermelon/Character/Vehicles/Hover")]
        public class HoverVehicleData : VehicleData
        {
            [SerializeField] private float turnRate = 40f;
    
            public override MovementBehavior CreateBehavior()
            {
                return new HoverMovementBehavior(turnRate * ProgressionController.VehicleEfficiencyMultiplier);
            }
        }
    }
    
  3. Create the asset. Open Create → Watermelon → Character → Vehicles → Hover and fill the values.

  4. Create the vehicle visual. Create a prefab with the model. Add VehicleVisualBehavior on the root and assign the Seat. Add track points, a rope point and boost points when the vehicle needs them. See Vehicle Visuals & Surface Effects.

  5. Create the Character prefab. Duplicate a prefab in Assets/Project Files/Game/Prefabs/Characters, for example Wheel Character. Assign the new visual to Default Visual Root and the new asset to Default Vehicle. Adjust the collider.

  6. Create the upgrade. Reuse VehicleEfficiencyUpgrade or create a new upgrade type. See Upgrades.

  7. Create the Character asset. Open Create → Watermelon → Progression → Character. Assign the prefab, the icon, the title, the run camera and the three upgrades.

  8. Link it to a level. Assign the Character to a Level. See How to add a new Level.

  9. Add a LevelSetup when needed. A vehicle may need its own launcher or ramp. See Level Setup.

Vehicle as a booster

A VehicleData asset can also be used by the Vehicle Swap booster. Use VisualOnlyVehicleData for a swap that changes only the look. See Boosters Overview.

Checklist