Ich bin grade neu beim programmieren und versuche bei einem normalen 2D Player Controller Skript den Spieler einmal zu flippen wenn er in die entsprechende Richtung läuft. Wie kann ich das machen?
Ich würde mich über Hilfe sehr freuen (:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public Rigidbody2D rb;
public Animator animator;
Vector2 movement;
void Start()
{
}
void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
animator.SetFloat("Horizontal", movement.x);
animator.SetFloat("Vertical", movement.x);
animator.SetFloat("Speed", movement.sqrMagnitude);
}
private void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
}