InputSynchronizable Class
Synchronize inputs (255 buttons and 255 axis maximum)
The input vales will update on this and other clients simultaneously.
Namespace: AlterunaAssembly: Alteruna.Trinity (in Alteruna.Trinity.dll) Version: 1.3.4
public class InputSynchronizable : CommunicationBridge,
IInput
- Inheritance
- Object Object Component Behaviour MonoBehaviour CommunicationBridge InputSynchronizable
- Implements
- IInput
Sync inputs and move transform based on those inputs.
Note that this does not sync position, after a while the positions could become unsynced.
using UnityEngine;
using Alteruna;
public class SyncedPlayerMovement : MonoBehaviour
{
//reference to a InputSynchronizable object in the scene with a avatar.
public InputSynchronizable InputSync;
public float Speed = 5;
private void Start() {
InputSync.AddAxis(new[] {"Horizontal", "Vertical"});
}
private void Update() {
float scaledSpeed = Speed * Time.deltaTime;
transform.Translate(
scaledSpeed * InputSync.AxesValues[0],
scaledSpeed * InputSync.AxesValues[1],
0);
}
}
AxesValues |
Get synced axes values by index
|
KeyValues |
Get synced button values by index
|
OnKeyUpdate |
Event for changes in key inputs.
passes KeyCode and state.
|
UseLocalInput |
Whether to use local input or use reply as input.
When false, all clients including the sender will receive inputs simultaneously. (assuming identical connection)
|