quantum-space-buddies/QSB/TransformSync/PlayerTransformSync.cs
AmazingAlek d762d35f56
resetting animation sync when leaving (#64)
* resetting (mostly) anim stuff when leaving

* setting local instance on player transform sync right away
2020-03-07 16:40:17 +01:00

46 lines
1.0 KiB
C#

using QSB.Animation;
using UnityEngine;
namespace QSB.TransformSync
{
public class PlayerTransformSync : TransformSync
{
public static PlayerTransformSync LocalInstance { get; private set; }
private Transform _playerModel;
public override void OnStartLocalPlayer()
{
LocalInstance = this;
}
private Transform GetPlayerModel()
{
if (!_playerModel)
{
_playerModel = Locator.GetPlayerBody().transform.Find("Traveller_HEA_Player_v2");
}
return _playerModel;
}
protected override Transform InitLocalTransform()
{
var body = GetPlayerModel();
GetComponent<AnimationSync>().InitLocal(body);
return body;
}
protected override Transform InitRemoteTransform()
{
var body = Instantiate(GetPlayerModel());
GetComponent<AnimationSync>().InitRemote(body);
return body;
}
}
}