Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback Combat System Suggestion

Discussion in 'General Discussion' started by cheleRV15, Aug 5, 2023.

Thread Status:
Not open for further replies.
  1. cheleRV15

    cheleRV15

    Joined:
    Aug 19, 2021
    Posts:
    5
    Hi,

    I am doing 2D videogame project. In this game I want to implement a simple combat system that consists of a light attack, heavy attack, and a ultimate. Each attack will have a different type of element like fire, water, etc.
    What I want to make in my game is that when pressing "q" for example it will change the element and with that it will change the attacks that you have. What I mean is that you will have a set of attacks for each element that change depending what element you select. Does anyone have a suggestion where to start or a tutorial that can be useful as a guide. This is what I have right now.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerAttacks : MonoBehaviour
    6. {
    7.     private bool isAttacking;
    8.  
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.        
    13.     }
    14.  
    15.     // Update is called once per frame
    16.     void Update()
    17.     {
    18.         if (isAttacking)
    19.         {
    20.             return;
    21.         }
    22.  
    23.         if (Input.GetKey(KeyCode.Mouse0))
    24.         {
    25.             LightAttack();
    26.         }
    27.  
    28.         else if (Input.GetKey(KeyCode.Mouse1))
    29.         {
    30.             HeavyAttack();
    31.         }
    32.  
    33.         else if (Input.GetKeyDown(KeyCode.R))
    34.         {
    35.             Ultimate();
    36.         }
    37.  
    38.     }
    39.  
    40.     void LightAttack()
    41.     {
    42.         if (!isAttacking)
    43.         {
    44.             isAttacking = true;
    45.             Debug.Log("Light attack");
    46.         }
    47.         isAttacking = false;
    48.     }
    49.  
    50.     void HeavyAttack()
    51.     {
    52.         if (!isAttacking)
    53.         {
    54.             isAttacking = true;
    55.             Debug.Log("Heavy attack");
    56.         }
    57.         isAttacking = false;
    58.     }
    59.  
    60.     void Ultimate()
    61.     {
    62.         if (!isAttacking)
    63.         {
    64.             isAttacking = true;
    65.             Debug.Log("Ultimate attack");
    66.         }
    67.         isAttacking = false;
    68.     }
    69. }
    70.  
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,075
    Don't cross-post please.
     
Thread Status:
Not open for further replies.