mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
Synchronize player animations
* just formatting * * moved message stuff to new project * generated .gitignore from https://gitignore.io/api/unity,visualstudio * fixed build event for message project * wip * . * . * :S:S:S * fixed working dir thing * fixed gitignore * adding .csproj.user * . * nothing works * fixed gitignore for UnityProject * wonky animation! \o/ * fixed csproj * merge * keeping this line solves the issue of animating local clones * removed trigger case
This commit is contained in:
parent
6ea6586acc
commit
e9a427f44d
51
QSB/AnimatorMirror.cs
Normal file
51
QSB/AnimatorMirror.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB
|
||||
{
|
||||
public class AnimatorMirror : MonoBehaviour
|
||||
{
|
||||
private Animator _from;
|
||||
private Animator _to;
|
||||
private bool _isRunning;
|
||||
|
||||
public void Init(Animator from, Animator to)
|
||||
{
|
||||
_from = from;
|
||||
_to = to;
|
||||
if (_from.runtimeAnimatorController == null)
|
||||
{
|
||||
_from.runtimeAnimatorController = _to.runtimeAnimatorController;
|
||||
}
|
||||
else if (_to.runtimeAnimatorController == null)
|
||||
{
|
||||
_to.runtimeAnimatorController = _from.runtimeAnimatorController;
|
||||
}
|
||||
_isRunning = true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!_isRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var fromParam in _from.parameters)
|
||||
{
|
||||
switch (fromParam.type)
|
||||
{
|
||||
case AnimatorControllerParameterType.Float:
|
||||
_to.SetFloat(fromParam.name, _from.GetFloat(fromParam.name));
|
||||
break;
|
||||
case AnimatorControllerParameterType.Int:
|
||||
_to.SetInteger(fromParam.name, _from.GetInteger(fromParam.name));
|
||||
break;
|
||||
case AnimatorControllerParameterType.Bool:
|
||||
_to.SetBool(fromParam.name, _from.GetBool(fromParam.name));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ namespace QSB
|
||||
{
|
||||
LocalInstance = this;
|
||||
_body = player;
|
||||
_body.gameObject.AddComponent<AnimatorMirror>().Init(_body.GetComponent<Animator>(), GetComponent<Animator>());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -35,6 +36,13 @@ namespace QSB
|
||||
_body.GetComponent<PlayerAnimController>().enabled = false;
|
||||
_body.Find("player_mesh_noSuit:Traveller_HEA_Player/player_mesh_noSuit:Player_Head").gameObject.layer = 0;
|
||||
_body.Find("Traveller_Mesh_v01:Traveller_Geo/Traveller_Mesh_v01:PlayerSuit_Helmet").gameObject.layer = 0;
|
||||
_body.gameObject.AddComponent<AnimatorMirror>().Init(GetComponent<Animator>(), _body.GetComponent<Animator>());
|
||||
}
|
||||
|
||||
var netAnim = GetComponent<NetworkAnimator>();
|
||||
for (var i = 0; i < GetComponent<Animator>().parameterCount; i++)
|
||||
{
|
||||
netAnim.SetParameterAutoSend(i, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,10 @@
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>$(StartWorkingDirectory)\..\OuterWilds_Data\Managed\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.AnimationModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(StartWorkingDirectory)\..\OuterWilds_Data\Managed\UnityEngine.AnimationModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>$(StartWorkingDirectory)\..\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
@ -86,6 +90,7 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AnimatorMirror.cs" />
|
||||
<Compile Include="DebugLog.cs" />
|
||||
<Compile Include="WakeUpSync.cs" />
|
||||
<Compile Include="QSBNetworkManager.cs" />
|
||||
|
@ -10,6 +10,9 @@ namespace QSB
|
||||
var assetBundle = QSB.Helper.Assets.LoadBundle("assets/network");
|
||||
playerPrefab = assetBundle.LoadAsset<GameObject>("assets/networkplayer.prefab");
|
||||
playerPrefab.AddComponent<NetworkPlayer>();
|
||||
|
||||
var anim = playerPrefab.AddComponent<Animator>();
|
||||
playerPrefab.AddComponent<NetworkAnimator>().animator = anim;
|
||||
}
|
||||
|
||||
public override void OnStartServer()
|
||||
|
Loading…
Reference in New Issue
Block a user