18 lines
498 B
C#
18 lines
498 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
[DisallowMultipleComponent]
|
|
public sealed class SetPlayerSpeedBehavior : NodeBehavior
|
|
{
|
|
public override void OnRun(string inputPortName)
|
|
{
|
|
if (base.IsAuthoritative && string.Equals(inputPortName, "Set", StringComparison.Ordinal))
|
|
{
|
|
int inputPlayerId = GetInputPlayerId("Player");
|
|
float speed = Mathf.Max(0f, (float)GetInputNumber("Speed"));
|
|
NodePlayerLocomotionRpc.Ensure()?.TrySetMoveSpeed(inputPlayerId, speed);
|
|
TriggerOutput("Done");
|
|
}
|
|
}
|
|
}
|