Hi!
I have a similar game, but it’s in 2D, so the method you are using here doesn’t really work for me…
is there a way to change my playermovement script into a similar one for mutliplayer purposes?
here is the code:
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);
}
}
Would really appreciate it!
Thanks for making this series!