using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FighterController : MonoBehaviour
{
    public enum State { Idle, Walking, Jumping, Attacking, Blocking }
    public State currentState;

    public float moveSpeed = 5f;
    public float jumpForce = 10f;
    private Rigidbody2D rb;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        currentState = State.Idle;
    }

    void Update()
    {
        // Movimentação Básica (Input do Teclado)
        float moveInput = Input.GetAxisRaw("Horizontal");
        rb.velocity = new Vector2(moveInput * moveSpeed, rb.velocity.y);

        // Pular
        if (Input.GetKeyDown(KeyCode.Space) && currentState != State.Jumping)
        {
            rb.velocity = new Vector2(rb.velocity.x, jumpForce);
            currentState = State.Jumping;
        }

        // Atacar (Ex: Hadouken / Soco)
        if (Input.GetKeyDown(KeyCode.J))
        {
            Attack();
        }
    }

    void Attack()
    {
        currentState = State.Attacking;
        Debug.Log("Soco aplicado! Animação de ataque ativada.");
        // Adicionar lógica de dano aqui
        currentState = State.Idle; // Retorna ao estado normal
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: