- Home /
NetworkAnimator.SetParameterAutoSend, no sync....
Please internet help, i cant figure what i'm doing wrong, i have tried several helpful guides to sync my triggered Animator
The Animator works with the trigger anim.SetTrigger("walk");
but when i try switshing to trigger the networkanimator, nothing happens. No triggering of animation and no sync over network.
This is my "cleaned" OVRplayer script:
using UnityEngine;
using UnityEngine.Networking;
[RequireComponent(typeof(CharacterController))]
public class OVRPlayerController_TEST : NetworkBehaviour
{
public GameObject Walk;
// Animator anim;
void Start()
{
// anim = Walk.GetComponent<Animator>();
}
public override void OnStartLocalPlayer()
{
NetworkAnimator netAnim = Walk.GetComponent<NetworkAnimator>();
netAnim.SetParameterAutoSend(0, true);
Walk.GetComponent<NetworkAnimator>().SetParameterAutoSend(0, true);
}
public override void PreStartClient()
{
NetworkAnimator netAnim = Walk.GetComponent<NetworkAnimator>();
netAnim.SetParameterAutoSend(0, true);
Walk.GetComponent<NetworkAnimator>().SetParameterAutoSend(0, true);
}
void Update()
{
if (OVRInput.Get(OVRInput.Button.One))
{
Walk.GetComponent<NetworkAnimator>().SetTrigger("walk");
//anim.SetTrigger("walk");
}
}
}
Please help this noob to fullfill my dream of a working Multiplayer "Polygon Nightmare" game FREE for all! :) Polygon Nightmare
Answer by 3janeiscool · Mar 04, 2019 at 09:51 AM
Ok. i found out the trigger cant be on a child object. moved everything to root of the "Networkplayer" and added this code sugested from a JP blog: unet-networkanimator
And added this for firing my trigger:
using UnityEngine;
using UnityEngine.Networking;
public class simpleNetworkTester : NetworkBehaviour
{
Animator m_Animator;
void Start()
{
m_Animator = GetComponent<Animator>();
}
void Update()
{
if (!isLocalPlayer)
return;
if (Input.GetKeyUp(KeyCode.Space))
{
m_Animator.enabled = false;
}
if (Input.GetKeyDown(KeyCode.Space))
{
m_Animator.enabled = true;
m_Animator.SetTrigger("walk");
CmdWalk();
}
}
[Command]
void CmdWalk()
{
RpcWalk();
}
[ClientRpc]
void RpcWalk()
{
if (!isLocalPlayer)
{
m_Animator.SetTrigger("walk");
}
}
}
Your answer
Follow this Question
Related Questions
VR Multiplayer Mirror LAN? 4 Answers
After 10 Seconds Player Spawning in Multiplayer 0 Answers
Close Multiplayer Connection within Single Scene 0 Answers
Check when a player finished spawning [Netcode For GameObjects!] 2 Answers
Player ReSpawn Logic 1 Answer