Skip to content

Game.Vehicles.WatercraftNavigation

Assembly: Assembly-CSharp (game code / runtime)
Namespace: Game.Vehicles

Type: struct (value type)

Base: Implements IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents simple navigation state for a watercraft entity in the ECS. Stores the target world position and direction the craft should move toward and a maximum speed. The struct is serializable for save/load and can be used directly as a component on entities or as a query parameter in jobs.


Fields

  • public Unity.Mathematics.float3 m_TargetPosition
    Holds the world-space target position the watercraft should navigate to. Typically used by path-following or steering systems to determine movement.

  • public Unity.Mathematics.float3 m_TargetDirection
    Holds the desired travel direction (usually normalized) toward the target. Systems can use this for orientation and steering corrections.

  • public System.Single m_MaxSpeed
    Maximum movement speed (units per second) allowed for the watercraft. Movement/physics systems should clamp velocity according to this value.

Properties

  • (none)
    This type exposes only public fields and does not declare C# properties.

Constructors

  • public WatercraftNavigation() (implicit default)
    No explicit constructor is defined in the source. The default parameterless constructor is available and initializes the fields to their default values (float3.zero and 0f). Initialize fields explicitly when creating an instance.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component data to the provided writer in the order: m_TargetPosition, m_TargetDirection, m_MaxSpeed. Use this when saving component state to persistent storage or streaming state between systems.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads component data from the provided reader into the fields in the same order as Serialize: m_TargetPosition, m_TargetDirection, m_MaxSpeed. Used when restoring component state from saved data or networked state.

Usage Example

// Create and assign a navigation component to an entity
var nav = new WatercraftNavigation
{
    m_TargetPosition = new float3(120.0f, 0.0f, 240.0f),
    m_TargetDirection = math.normalize(new float3(1.0f, 0.0f, 0.5f)),
    m_MaxSpeed = 8.5f
};

entityManager.AddComponentData(watercraftEntity, nav);

// In a system you may read/update the component:
var navData = entityManager.GetComponentData<WatercraftNavigation>(watercraftEntity);
navData.m_TargetPosition = new float3(200f, 0f, 300f);
entityManager.SetComponentData(watercraftEntity, navData);

// Serialization example (pseudo-usage depends on concrete writer/reader types)
writer.Write(nav.m_TargetPosition);
writer.Write(nav.m_TargetDirection);
writer.Write(nav.m_MaxSpeed);

Notes: - m_TargetDirection is expected to be a direction vector; normalizing before storing is recommended if systems assume unit length. - Because this type implements IComponentData, it is intended for use with Unity's ECS (DOTS) style workflows and can be used in jobified systems via IQueryTypeParameter.