Add project files.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace MSCO
|
||||
{
|
||||
/// <summary>Bewegt den anderen Spieler weich zur zuletzt empfangenen Position.</summary>
|
||||
public class RemotePlayer : MonoBehaviour
|
||||
{
|
||||
Vector3 targetPos;
|
||||
float targetRotY;
|
||||
|
||||
public void SetTarget(PlayerState state)
|
||||
{
|
||||
targetPos = state.Position;
|
||||
targetRotY = state.RotationY;
|
||||
}
|
||||
|
||||
public void Tick(float dt)
|
||||
{
|
||||
// Bei großen Sprüngen (Teleport, Laden) direkt setzen statt gleiten
|
||||
if ((transform.position - targetPos).sqrMagnitude > 100f)
|
||||
transform.position = targetPos;
|
||||
else
|
||||
transform.position = Vector3.Lerp(transform.position, targetPos, dt * 15f);
|
||||
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation,
|
||||
Quaternion.Euler(0f, targetRotY, 0f), dt * 15f);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user