+ Character Sprite

+ Character animations (not moving)
# Character movement
This commit is contained in:
janis
2022-02-08 18:53:20 +01:00
parent 07d7ace073
commit 70352c3f32
40 changed files with 2052 additions and 31 deletions

View File

@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[SerializeField] float moveSpeed = 5f;
[SerializeField] Rigidbody2D rb;
[SerializeField] Animator animator;
Vector2 movement;
private void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
animator.SetFloat("Horizontal", movement.x);
animator.SetFloat("Vertical", movement.y);
animator.SetFloat("Speed", movement.sqrMagnitude);
}
private void FixedUpdate()
{
if (rb != null)
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
else
{
Debug.LogError("No Rigidbody2D found in PlayerMovement.cs");
}
}
}