You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Driftology/Assets/Scripts/.NetworkController.cs

27 lines
649 B
C#

using Fusion;
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class NetworkController : NetworkBehaviour
{
public float moveSpeed = 5f;
private Rigidbody rb;
private Vector3 moveDirection;
public override void Spawned()
{
rb = GetComponent<Rigidbody>();
}
public override void FixedUpdateNetwork()
{
if (GetInput(out CarNetworkInput input))
{
moveDirection = new Vector3(input.Horizontal, 0f, input.Vertical).normalized;
Vector3 move = moveDirection * moveSpeed * Runner.DeltaTime;
rb.MovePosition(rb.position + move);
}
}
}