Hey guys, I'm watching multiple courses on gamedev.tv, unfortunately I can't seem to find a 2D option for multiplayer and so I went with a course using 3D instead.
everything so far I could figure stuff out, except for the player movement script..
this is my playermovement script so far:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public Rigidbody2D rb;
public Animator anim;
Vector2 movement;
private void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
anim.SetFloat("Horizontal", movement.x);
anim.SetFloat("Vertical", movement.y);
anim.SetFloat("Speed", movement.sqrMagnitude);
if (Input.GetAxisRaw("Horizontal") == 1 || Input.GetAxisRaw("Horizontal") == -1 || Input.GetAxisRaw("Vertical") == 1 || Input.GetAxisRaw("Vertical") == -1)
{
anim.SetFloat("lastMoveX", Input.GetAxisRaw("Horizontal"));
anim.SetFloat("lastMoveY", Input.GetAxisRaw("Vertical"));
}
if(movement.magnitude > 1)
{
movement.Normalize();
}
}
private void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
}
if I use the Mirror build in multiplayer right now, the player just moves both characters, which is obviously not really what I want..
would really appreciate if someone could help me figure this out!