- Home /
Online Rpg Animation does not work
Hello, I have a game that I would like to make online, in the current step I am testing the movement of two players in Match Maker, one in unity and another in an android. When I connect the two, I can move and see the movement of the two players, but the player can not see animation of the other player, only yours. (Knowing that it needs a transition in the animator to perform) Follow the drive code, and images of each device at the same time. Thanks any help or tip.
using UnityEngine; using System.Collections; using UnityStandardAssets.CrossPlatformInput; using UnityEngine.Networking;
public class MoveJoystick : NetworkBehaviour {
public float moveSpeed = 5;
private bool playerMoving;
private Vector2 lastMove;
private Animator anim;
private Rigidbody2D myBody;
private float velocityX;
private float velocityY;
void Start ()
{
anim = GetComponent<Animator>();
myBody = GetComponent<Rigidbody2D>();
}
void Update ()
{
if (!isLocalPlayer) {
return;
}
Walking();
}
void Walking(){
playerMoving = false;
if(CrossPlatformInputManager.GetAxisRaw("Horizontal")>0.4f || CrossPlatformInputManager.GetAxisRaw("Horizontal")<-0.4f)
{
velocityX = CrossPlatformInputManager.GetAxisRaw("Horizontal") * moveSpeed;
// transform.Translate(new Vector3(CrossPlatformInputManager.GetAxis("Horizontal"), 0f, 0f) * moveSpeed * speedModificator);
playerMoving = true;
lastMove = new Vector2(CrossPlatformInputManager.GetAxisRaw("Horizontal"), 0f);
}
if (CrossPlatformInputManager.GetAxisRaw("Vertical") > 0.4f || CrossPlatformInputManager.GetAxisRaw("Vertical") < -0.4f)
{
velocityY = CrossPlatformInputManager.GetAxisRaw("Vertical") * moveSpeed;
// transform.Translate(new Vector3(0f, CrossPlatformInputManager.GetAxis("Vertical"), 0f) * moveSpeed * speedModificator);
playerMoving = true;
lastMove = new Vector2(0f,CrossPlatformInputManager.GetAxisRaw("Vertical"));
}
myBody.velocity = new Vector2(velocityX, velocityY);
if (CrossPlatformInputManager.GetAxisRaw("Horizontal") < 0.4f && CrossPlatformInputManager.GetAxisRaw("Horizontal") > -0.4f)
{
myBody.velocity = new Vector2(0f, myBody.velocity.y);
}
if (CrossPlatformInputManager.GetAxisRaw("Vertical") < 0.4f && CrossPlatformInputManager.GetAxisRaw("Vertical") > -0.4f)
{
myBody.velocity = new Vector2(myBody.velocity.x, 0f);
}
if (HurtEnemy.isAtk == true) {
lastMove = PlayerTurn.lastMovem;
}
anim.SetFloat("MoveX", CrossPlatformInputManager.GetAxisRaw("Horizontal"));
anim.SetFloat("MoveY", CrossPlatformInputManager.GetAxisRaw("Vertical"));
anim.SetBool("PlayerMoving", playerMoving);
anim.SetFloat("LastMoveX", lastMove.x);
anim.SetFloat("LastMoveY", lastMove.y);
}
}
Comment