NewInputSync Class

Synchronizes input actions across multiple users in a room using the new input system.

Definition

Namespace: Alteruna.Multiplayer
Assembly: Alteruna (in Alteruna.dll) Version: 2.0.1+a1176e08a0b4a6bfd8fefeddde6163a16d29e5ab
C#
public class NewInputSync : Synchronizable
Inheritance
Object    Object    Component    Behaviour    MonoBehaviour    CommunicationBridge    CommunicationBridgeUID    Synchronizable    NewInputSync

Example

This example demonstrates how to use the NewInputSync component to synchronize an input action for horizontal movement.
C#
using UnityEngine;
using Alteruna.Multiplayer;

[RequireComponent(typeof(NewInputSync))]
public class NewInputSyncTest : MonoBehaviour
{
    public float MoveSpeed = 5f;

    private NewInputSync _inputSync;

    // Type specific action
    private NewInputSync.InputActionSync.Action<float> _horizontal;

    // Unspecified type action
    private NewInputSync.InputActionSync _vertical;

    private void Start()
    {
        var inputSync = GetComponent<NewInputSync>();
        // Get casted action
        _horizontal = inputSync.FindAction<float>("Horizontal");
        // Get unspecified type action
        _vertical = inputSync.FindAction("Vertical");
    }

    private void Update()
    {
        transform.Translate(
            // Get value directly from the action
            _horizontal.GetValue() * MoveSpeed * Time.deltaTime,
            // Attempt to get value from the unspecified type action as float
            _vertical.GetValue<float>() * MoveSpeed * Time.deltaTime,
            0
        );
    }
}

Constructors

Methods

AssembleData
(Overrides SynchronizableAssembleData(Writer, SerializeInfo))
DisassembleData
(Overrides SynchronizableDisassembleData(Reader, UnserializeInfo))
FindAction(Guid) Retrieves an input action synchronization object corresponding to the specified unique identifier.
FindAction(String) Finds an input action synchronization object by its name or identifier string.
FindActionT(String) Finds the synchronized input action associated with the specified name or identifier string and casts it to the specified type.
FindActionId Finds the unique identifier of an input action by its name or identifier string.
Possessed
(Overrides CommunicationBridgePossessed(Boolean, User))
Start 
Unpossessed
(Overrides CommunicationBridgeUnpossessed)

Fields

See Also