Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question How to go to the next round

Discussion in 'Scripting' started by CaptainVega, Jan 27, 2023.

  1. CaptainVega

    CaptainVega

    Joined:
    Jan 26, 2023
    Posts:
    102
    I found the cause.
    Code (CSharp):
    1.  
    2. void Start()
    3.     {
    4.        
    5.         myBody = GetComponent<Rigidbody>();
    6.         animator = GetComponent<Animator>();
    7.         audioPlayer = GetComponent<AudioSource>();
    8.         StartPoint = transform.position;
    9.         // I found the cause.
    10. if (player == PlayerType.AI)
    11.         {
    12.  
    13.  
    14.             if (PlayerPrefs.GetInt("cuboSelect") == 1)
    15.             {
    16.                 oponent = GameObject.Find("Cube").GetComponent<Fighter>();
    17.  
    18.             }
    19.             else if (PlayerPrefs.GetInt("ryuSelect") == 1)
    20.             {
    21.                 oponent = GameObject.Find("Ryu").GetComponent<Fighter>();
    22.  
    23.             }
    24.         }
    25.  
    26.     }
    When I was experimenting with how to do character selection, I thought that this is the way to make the "public Fighter opponent;" the character that I choose is changed in the "public Fighter opponent;" to Ken, I thought a way to change opponent, until I figured it out.

    Is there a solution that will stop Ken's hit animation from freezing?
     
  2. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    Sincerely I don't know. Why not contact the author of the animator? Alternatively you could follow a few tutorials on coding and animation.
     
  3. CaptainVega

    CaptainVega

    Joined:
    Jan 26, 2023
    Posts:
    102
    I did it myself but the author did not explain this, if I have followed that video of that author, the author's name is Multiverso Sensorial, he is a Uruguayan who explains to me how to make a selection of characters with playerpref (in Spanish).

    I saw another "opponent" problem. If I set Ryu in the Inspector to "opponent" Ken's animation stroke starts to slow down, if I set Cube in the Inspector to "opponent" Ken's animation stroke does not slow down, I say why? if he's smacking Ryu? I don't understand it, it wasn't like that or what's happening. ok, i'll try watch lots of videos or i'll check my backup.
     
  4. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    If you have done it yourself you can separate your animator in two with one version for player and one for AI, that will be simpler to maintain I guess.
     
    CaptainVega likes this.
  5. CaptainVega

    CaptainVega

    Joined:
    Jan 26, 2023
    Posts:
    102
    i guess you are right. And I think that it will be a little difficult, but I will try, but I will just do it just in case.
     
  6. CaptainVega

    CaptainVega

    Joined:
    Jan 26, 2023
    Posts:
    102
    It turns out what I said is true, it is difficult to change the script as separate because neither of them detects the hits.
     
  7. CaptainVega

    CaptainVega

    Joined:
    Jan 26, 2023
    Posts:
    102
    This is what I did, but it's a lot of coding, that's why I'll do it by myself.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. public class Fighter : MonoBehaviour
    6. {
    7.     public enum PlayerType
    8.     {
    9.         HUMAN, AI
    10.     };
    11.     public static float MAX_HEALTH = 100f;
    12.     public BannerController banner;
    13.     public float healt = MAX_HEALTH;
    14.     public string fighterName;
    15.     public AI oponent;
    16.     public bool enable;
    17.     [SerializeField]  private float speed = 0.0f;
    18.     [SerializeField] private float acceleration = 0.1f;
    19.     [SerializeField] private float deceleration = 0.5f;
    20.     public PlayerType player;
    21.     public HitColider hitColider1;
    22.     public HitColider hitColider2;
    23.     public Transform luchador;
    24.  
    25.     public FighterStates currentState = FighterStates.IDLE;
    26.     public HudController hudController;
    27.     protected Animator animator;
    28.     private Rigidbody myBody;
    29.     private AudioSource audioPlayer;
    30.  
    31.     public BattleController battleController;
    32.  
    33.  
    34.     //for AI only
    35.     private float random;
    36.     private float randomSetTime;
    37.  
    38.     public Image roundOne;
    39.  
    40.     public Image primerRound;
    41.  
    42.     // ResetStats
    43.     public Vector3 StartPoint;
    44.  
    45.     // FighterStates currentState = FighterStates.IDLE;
    46.     public void ResetStats()
    47.     {
    48.         enable = false;
    49.      
    50.  
    51.         if (player == PlayerType.HUMAN)
    52.         {
    53.             animator.SetBool("SpecialMoves", false);
    54.             animator.SetBool("WALK_BACK", false);
    55.             animator.SetBool("WALK", false);
    56.             animator.SetBool("DEFEND", false);
    57.             animator.SetBool("DUCK", false);
    58.          
    59.         }
    60.      
    61.          
    62.     }
    63.     public void Life()
    64.     {
    65.      
    66.         animator.SetFloat("health", 1);
    67.         animator.SetFloat("oponent_health", 1);
    68.         healt = MAX_HEALTH ;
    69.         animator.SetFloat("random", 0f);
    70.         animator.SetBool("oponent_attacking", false);
    71.         animator.SetFloat("distanceToOponent", 0f);
    72.         FighterStates currentState = FighterStates.IDLE;
    73.         transform.position = StartPoint;
    74.         hudController.leftBar.size += 1f;
    75.         hudController.rightBar.size += 1f;
    76.      
    77.     }
    78.     public void Cpu()
    79.     {
    80.         if (player == PlayerType.AI)
    81.         {
    82.        
    83.             enable = false;
    84.             animator.SetFloat("random", 0f);
    85.             animator.SetBool("oponent_attacking", false);
    86.             animator.SetFloat("distanceToOponent", 0f);
    87.         }
    88.     }
    89.  
    90.     public int roundWin;
    91.     public Text scoreTextRound;
    92.     public void addScoreRound()
    93.     {
    94.         roundWin = roundWin + 1;
    95.         scoreTextRound.text = roundWin.ToString();
    96.  
    97.     }
    98.     public void CheckVictory()
    99.     {
    100.         if (roundWin >= 2)
    101.         {
    102.             Debug.Log("Win Ryu");
    103.             primerRound.enabled = true;
    104.             battleController.player1.roundOne.enabled = false;
    105.             battleController.player2.roundOne.enabled = false;
    106.  
    107.         }
    108.     }
    109.  
    110.     // Use this for initialization
    111.     void Start()
    112.     {
    113.      
    114.         myBody = GetComponent<Rigidbody>();
    115.         animator = GetComponent<Animator>();
    116.         audioPlayer = GetComponent<AudioSource>();
    117.         StartPoint = transform.position;
    118.    
    119.  
    120.     }
    121.  
    122.     public void UpdateHumanInput()
    123.     {
    124.      
    125.             bool moverseoprimido = Input.GetKey(KeyCode.RightArrow);
    126.  
    127.  
    128.  
    129.         if (moverseoprimido && speed < 1.0f)
    130.         {
    131.             speed += Time.deltaTime * acceleration;
    132.         }
    133.         if (!moverseoprimido && speed > 0.0f)
    134.         {
    135.             speed -= Time.deltaTime * deceleration;
    136.         }
    137.         if (!moverseoprimido && speed < 0.0f)
    138.         {
    139.             speed = 0.0f;
    140.         }
    141.         if (Input.GetAxis("Horizontal") < -0.1)
    142.         {
    143.  
    144.             if (oponent.attacking)
    145.             {
    146.                 animator.SetBool("WALK_BACK", false);
    147.                 animator.SetBool("DEFEND", true);
    148.             }
    149.             else
    150.             {
    151.                 animator.SetBool("WALK_BACK", true);
    152.                 animator.SetBool("DEFEND", false);
    153.             }
    154.         }
    155.         else
    156.         {
    157.             animator.SetBool("WALK_BACK", false);
    158.             animator.SetBool("DEFEND", false);
    159.         }
    160.  
    161.         if (Input.GetAxis("Vertical") < -0.1)
    162.         {
    163.             animator.SetBool("DUCK", true);
    164.         }
    165.         else
    166.         {
    167.             animator.SetBool("DUCK", false);
    168.         }
    169.  
    170.         if (Input.GetKeyDown(KeyCode.UpArrow))
    171.         {
    172.             animator.SetTrigger("JUMP");
    173.         }
    174.  
    175.         if (Input.GetKeyDown(KeyCode.Space))
    176.         {
    177.          
    178.             animator.SetTrigger("PUNCH_R");
    179.          
    180.         }
    181.         else
    182.         {
    183.             animator.SetBool("attackOn", false);
    184.         }
    185.         if (Input.GetKeyDown(KeyCode.U))
    186.         {
    187.             animator.SetTrigger("PUNCH_R");
    188.             hitColider2.damage =+ 2;
    189.         }
    190.         if (Input.GetKeyDown(KeyCode.K))
    191.         {
    192.             animator.SetTrigger("KICK_R");
    193.         }
    194.  
    195.         if (Input.GetKeyDown(KeyCode.Space))
    196.         {
    197.             animator.SetTrigger("HADOKEN");
    198.             animator.SetBool("SpecialMoves", true);
    199.         }
    200.         else
    201.         {
    202.             animator.SetBool("SpecialMoves", false);
    203.         }
    204.  
    205.  
    206.         animator.SetFloat("Walk", speed);
    207.      
    208.     }
    209.  
    210.  
    211.  
    212.     // Update is called once per frame
    213.     void Update()
    214.     {
    215.         animator.SetFloat("health", healtPercent);
    216.      
    217.             if (oponent != null)
    218.             {
    219.                 animator.SetFloat("oponent_health", oponent.healtPercent);
    220.              
    221.             }
    222.             else
    223.             {
    224.                 animator.SetFloat("oponent_health", 1);
    225.  
    226.             }
    227.          
    228.  
    229.             if (enable)
    230.             {
    231.                 if (player == PlayerType.HUMAN)
    232.                 {
    233.                     UpdateHumanInput();
    234.  
    235.  
    236.                 }
    237.  
    238.             }
    239.  
    240.             if (healt <= 0 && currentState != FighterStates.DEAD)
    241.             {
    242.                 animator.SetTrigger("DEAD");
    243.  
    244.             }
    245.         }
    246.  
    247.     private float getDistanceToOponennt()
    248.     {
    249.         return Mathf.Abs(transform.position.x - oponent.transform.position.x);
    250.  
    251.     }
    252.  
    253.     public virtual void hurtCpu(float damage)
    254.     {
    255.      
    256.             if (!invulnerable)
    257.             {
    258.                 if (defending)
    259.                 {
    260.                     damage *= 0.2f;
    261.                 }
    262.                 if (healt >= damage)
    263.                 {
    264.                     healt -= damage;
    265.                 }
    266.                 else
    267.                 {
    268.                     healt = 0;
    269.                 }
    270.  
    271.                 if (healt > 0)
    272.                 {
    273.                     animator.SetTrigger("TAKE_HIT");
    274.                 }
    275.  
    276.  
    277.  
    278.  
    279.             }
    280.      
    281.      
    282.        
    283.  
    284.  
    285.  
    286.  
    287.    
    288.     }
    289.  
    290.  
    291.  
    292.     public void playSound(AudioClip sound)
    293.     {
    294.         GameUtils.playSound(sound, audioPlayer);
    295.     }
    296.  
    297.     public bool invulnerable
    298.     {
    299.         get
    300.         {
    301.             return currentState == FighterStates.TAKE_HIT
    302.                 || currentState == FighterStates.TAKE_HIT_DEFEND
    303.                 || currentState == FighterStates.TAKE_HITVolar
    304.                     || currentState == FighterStates.DEAD;
    305.         }
    306.     }
    307.  
    308.     public bool defending
    309.     {
    310.         get
    311.         {
    312.             return currentState == FighterStates.DEFEND
    313.                 || currentState == FighterStates.TAKE_HIT_DEFEND;
    314.         }
    315.     }
    316.  
    317.     public bool attacking
    318.     {
    319.         get
    320.         {
    321.             return currentState == FighterStates.ATTACK;
    322.  
    323.         }
    324.     }
    325.  
    326.     public float healtPercent
    327.     {
    328.         get
    329.         {
    330.             return healt / MAX_HEALTH;
    331.         }
    332.     }
    333.  
    334.     public Rigidbody body
    335.     {
    336.         get
    337.         {
    338.             return this.myBody;
    339.         }
    340.     }
    341. }
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. public class AI : MonoBehaviour
    6. {
    7.     public enum PlayerType
    8.     {
    9.         AI
    10.     };
    11.     public static float MAX_HEALTH = 100f;
    12.     public BannerController banner;
    13.     public float healt = MAX_HEALTH;
    14.     public string fighterName;
    15.     public Fighter oponent;
    16.     public bool enable;
    17.  
    18.     public PlayerType player;
    19.     public HitColiderCpu hitColider1;
    20.     public HitColiderCpu hitColider2;
    21.     public Transform luchador;
    22.  
    23.     public FighterStates currentState = FighterStates.IDLE;
    24.     public HudController hudController;
    25.     protected Animator animator;
    26.     private Rigidbody myBody;
    27.     private AudioSource audioPlayer;
    28.  
    29.     public BattleController battleController;
    30.  
    31.     private float random;
    32.     private float randomSetTime;
    33.  
    34.     public Image roundOne;
    35.  
    36.     public Image primerRound;
    37.  
    38.     // ResetStats
    39.     public Vector3 StartPoint;
    40.  
    41.     // FighterStates currentState = FighterStates.IDLE;
    42.  
    43.     public void Life()
    44.     {
    45.  
    46.         animator.SetFloat("health", 1);
    47.         animator.SetFloat("oponent_health", 1);
    48.         healt = MAX_HEALTH;
    49.         animator.SetFloat("random", 0f);
    50.         animator.SetBool("oponent_attacking", false);
    51.         animator.SetFloat("distanceToOponent", 0f);
    52.         FighterStates currentState = FighterStates.IDLE;
    53.         transform.position = StartPoint;
    54.         hudController.leftBar.size += 1f;
    55.         hudController.rightBar.size += 1f;
    56.  
    57.     }
    58.  
    59.     public void Cpu()
    60.     {
    61.         if (player == PlayerType.AI)
    62.         {
    63.  
    64.             enable = false;
    65.             animator.SetFloat("random", 0f);
    66.             animator.SetBool("oponent_attacking", false);
    67.             animator.SetFloat("distanceToOponent", 0f);
    68.         }
    69.     }
    70.  
    71.     public int roundWin;
    72.     public Text scoreTextRound;
    73.     public void addScoreRound()
    74.     {
    75.         roundWin = roundWin + 1;
    76.         scoreTextRound.text = roundWin.ToString();
    77.  
    78.     }
    79.     public void CheckVictory()
    80.     {
    81.         if (roundWin >= 2)
    82.         {
    83.             Debug.Log("Win Ryu");
    84.             primerRound.enabled = true;
    85.             battleController.player1.roundOne.enabled = false;
    86.             battleController.player2.roundOne.enabled = false;
    87.  
    88.         }
    89.     }
    90.  
    91.     // Use this for initialization
    92.     void Start()
    93.     {
    94.  
    95.         myBody = GetComponent<Rigidbody>();
    96.         animator = GetComponent<Animator>();
    97.         audioPlayer = GetComponent<AudioSource>();
    98.         StartPoint = transform.position;
    99.    
    100.     }
    101.     public void UpdateAiInput()
    102.     {
    103.  
    104.         animator.SetBool("defending", defending);
    105.         //animator.SetBool ("invulnerable", invulnerable);
    106.         //animator.SetBool ("enable", enable);
    107.  
    108.         animator.SetBool("oponent_attacking", oponent.attacking);
    109.         animator.SetFloat("distanceToOponent", getDistanceToOponennt());
    110.  
    111.         if (Time.time - randomSetTime > 1)
    112.         {
    113.             random = Random.value;
    114.             randomSetTime = Time.time;
    115.         }
    116.         animator.SetFloat("random", random);
    117.  
    118.     }
    119.  
    120.     // Update is called once per frame
    121.     void Update()
    122.     {
    123.         animator.SetFloat("health", healtPercent);
    124.  
    125.         if (oponent != null)
    126.         {
    127.             animator.SetFloat("oponent_health", oponent.healtPercent);
    128.  
    129.         }
    130.         else
    131.         {
    132.             animator.SetFloat("oponent_health", 1);
    133.  
    134.         }
    135.  
    136.  
    137.         if (enable)
    138.         {
    139.             if (player == PlayerType.AI)
    140.             {
    141.              
    142.  
    143.  
    144.                 UpdateAiInput();
    145.             }
    146.  
    147.         }
    148.  
    149.         if (healt <= 0 && currentState != FighterStates.DEAD)
    150.         {
    151.             animator.SetTrigger("DEAD");
    152.  
    153.         }
    154.     }
    155.  
    156.     private float getDistanceToOponennt()
    157.     {
    158.         return Mathf.Abs(transform.position.x - oponent.transform.position.x);
    159.  
    160.     }
    161.  
    162.     public virtual void hurt(float damage)
    163.     {
    164.  
    165.         if (!invulnerable)
    166.         {
    167.             if (defending)
    168.             {
    169.                 damage *= 0.2f;
    170.             }
    171.             if (healt >= damage)
    172.             {
    173.                 healt -= damage;
    174.             }
    175.             else
    176.             {
    177.                 healt = 0;
    178.             }
    179.  
    180.             if (healt > 0)
    181.             {
    182.                 animator.SetTrigger("TAKE_HIT");
    183.             }
    184.  
    185.  
    186.  
    187.  
    188.         }
    189.  
    190.  
    191.  
    192.  
    193.  
    194.  
    195.  
    196.  
    197.     }
    198.  
    199.     public void playSound(AudioClip sound)
    200.     {
    201.         GameUtils.playSound(sound, audioPlayer);
    202.     }
    203.  
    204.     public bool invulnerable
    205.     {
    206.         get
    207.         {
    208.             return currentState == FighterStates.TAKE_HIT
    209.                 || currentState == FighterStates.TAKE_HIT_DEFEND
    210.                 || currentState == FighterStates.TAKE_HITVolar
    211.                     || currentState == FighterStates.DEAD;
    212.         }
    213.     }
    214.  
    215.     public bool defending
    216.     {
    217.         get
    218.         {
    219.             return currentState == FighterStates.DEFEND
    220.                 || currentState == FighterStates.TAKE_HIT_DEFEND;
    221.         }
    222.     }
    223.  
    224.     public bool attacking
    225.     {
    226.         get
    227.         {
    228.             return currentState == FighterStates.ATTACK;
    229.  
    230.         }
    231.     }
    232.     public bool attackingVolar
    233.     {
    234.         get
    235.         {
    236.             return currentState == FighterStates.ATTACKVolar;
    237.         }
    238.     }
    239.     public float healtPercent
    240.     {
    241.         get
    242.         {
    243.             return healt / MAX_HEALTH;
    244.         }
    245.     }
    246.  
    247.     public Rigidbody body
    248.     {
    249.         get
    250.         {
    251.             return this.myBody;
    252.         }
    253.     }
    254.  
    255.     public static implicit operator AI(Fighter v)
    256.     {
    257.         throw new System.NotImplementedException();
    258.     }
    259. }
    260. [code=CSharp]using System.Collections;
    261. using System.Collections.Generic;
    262. using UnityEngine;
    263.  
    264. public class FighterStageBehavior : StateMachineBehaviour
    265. {
    266.  
    267.     public FighterStates behaviorState;
    268.     public AudioClip soundEffect;
    269.  
    270.     public float horizontalForce;
    271.     public float verticalForce;
    272.  
    273.     protected Fighter fighter;
    274.  
    275.     override public void OnStateEnter(Animator animator,
    276.         AnimatorStateInfo stateInfo, int layerIndex)
    277.     {
    278.         if (fighter == null)
    279.         {
    280.             fighter = animator.gameObject.GetComponent<Fighter>();
    281.         }
    282.         fighter.currentState = behaviorState;
    283.  
    284.         if (soundEffect != null)
    285.         {
    286.             fighter.playSound(soundEffect);
    287.         }
    288.  
    289.         fighter.body.AddRelativeForce(new Vector3(0, verticalForce, 0));
    290.  
    291.     }
    292.  
    293.     override public void OnStateUpdate(
    294.         Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    295.     {
    296.         fighter.body.AddRelativeForce(new Vector3(0, 0, horizontalForce));
    297.     }
    298. }
    [/code]
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class AIStageBehavior : StateMachineBehaviour
    6. {
    7.     public FighterStates behaviorState;
    8.     public AudioClip soundEffect;
    9.  
    10.     public float horizontalForce;
    11.     public float verticalForce;
    12.  
    13.     protected AI fighter;
    14.  
    15.     override public void OnStateEnter(Animator animator,
    16.         AnimatorStateInfo stateInfo, int layerIndex)
    17.     {
    18.         if (fighter == null)
    19.         {
    20.             fighter = animator.gameObject.GetComponent<AI>();
    21.         }
    22.         fighter.currentState = behaviorState;
    23.  
    24.         if (soundEffect != null)
    25.         {
    26.             fighter.playSound(soundEffect);
    27.         }
    28.  
    29.         fighter.body.AddRelativeForce(new Vector3(0, verticalForce, 0));
    30.  
    31.     }
    32.  
    33.     override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    34.     {
    35.         fighter.body.AddRelativeForce(new Vector3(0, 0, horizontalForce));
    36.     }
    37. }
    38.  
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class FighterStageBehavior : StateMachineBehaviour
    6. {
    7.  
    8.     public FighterStates behaviorState;
    9.     public AudioClip soundEffect;
    10.  
    11.     public float horizontalForce;
    12.     public float verticalForce;
    13.  
    14.     protected Fighter fighter;
    15.  
    16.     override public void OnStateEnter(Animator animator,
    17.         AnimatorStateInfo stateInfo, int layerIndex)
    18.     {
    19.         if (fighter == null)
    20.         {
    21.             fighter = animator.gameObject.GetComponent<Fighter>();
    22.         }
    23.         fighter.currentState = behaviorState;
    24.  
    25.         if (soundEffect != null)
    26.         {
    27.             fighter.playSound(soundEffect);
    28.         }
    29.  
    30.         fighter.body.AddRelativeForce(new Vector3(0, verticalForce, 0));
    31.  
    32.     }
    33.  
    34.     override public void OnStateUpdate(
    35.         Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    36.     {
    37.         fighter.body.AddRelativeForce(new Vector3(0, 0, horizontalForce));
    38.     }
    39. }
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class HitColider : MonoBehaviour
    6. {
    7.     public string punchName;
    8.     public float damage;
    9.  
    10.     public Fighter owner;
    11.     void OnTriggerEnter(Collider other)
    12.     {
    13.         Fighter somebody = other.gameObject.GetComponent<Fighter>();
    14.         if (owner.attacking)
    15.         {
    16.             if (somebody != null && somebody != owner)
    17.             {
    18.                 somebody.hurtCpu(damage);
    19.             }
    20.         }
    21.     }
    22. }
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class HitColiderCpu : MonoBehaviour
    6. {
    7.     public string punchName;
    8.     public float damage;
    9.  
    10.     public AI owner;
    11.     void OnTriggerEnter(Collider other)
    12.     {
    13.         AI somebody = other.gameObject.GetComponent<AI>();
    14.         if (owner.attacking)
    15.         {
    16.             if (somebody != null && somebody != owner)
    17.             {
    18.                 somebody.hurt(damage);
    19.             }
    20.         }
    21.     }
    22. }
    23.  
     
  8. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    If you don't detect hits it's a collider issue. As I said already, use Debug.Log() statements to figure out what is going on.
     
    CaptainVega likes this.
  9. CaptainVega

    CaptainVega

    Joined:
    Jan 26, 2023
    Posts:
    102
    now i fixed it but it still slows down ken's punch animation. (I think now is the time to get to work.)
     
  10. CaptainVega

    CaptainVega

    Joined:
    Jan 26, 2023
    Posts:
    102
    I think this script is causing the slow down of ken's punch animation.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class HitColiderCpu : MonoBehaviour
    6. {
    7.     public string punchName;
    8.     public float damage;
    9.  
    10.     public AI owner;
    11.     void OnTriggerEnter(Collider other)
    12.     {
    13.         Fighter somebody = other.gameObject.GetComponent<Fighter>();
    14.         if (owner.attacking)
    15.         {
    16.             if (somebody != null && somebody != owner)
    17.             {
    18.                 somebody.hurt(damage);
    19.                 Debug.Log("funciona a Cpu?");
    20.             }
    21.         }
    22.     }
    23. }
    24.  
    Do you have an idea how to solve?
     
  11. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    When you click on it from the animator window it is also slow or not?
     
  12. CaptainVega

    CaptainVega

    Joined:
    Jan 26, 2023
    Posts:
    102
    yes.
     
  13. CaptainVega

    CaptainVega

    Joined:
    Jan 26, 2023
    Posts:
    102
    and more, when he takes life out of Ryu he begins to slow down to 0f, when he has Ryu's life at 100f his ken animation hit is his original speed. (as "Speed 1".)
     
  14. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    Then it's an animation issue you won't find the answer in your code.
     
    CaptainVega likes this.
  15. CaptainVega

    CaptainVega

    Joined:
    Jan 26, 2023
    Posts:
    102
    I found the person responsible but i don't know if i can fix it.
     

    Attached Files:

  16. CaptainVega

    CaptainVega

    Joined:
    Jan 26, 2023
    Posts:
    102
    well, so that was the problem, and I'm very angry with that "Multiplier":mad: (for making me waste my time), anyway, thanks again dlorre and the things that I did not know:);).
     
    Last edited: Feb 24, 2023
  17. CaptainVega

    CaptainVega

    Joined:
    Jan 26, 2023
    Posts:
    102
    The truth is that I want to create a new AI so that it has Ken hadoken or shoryuken, and can change the difficulty, but not now, I prefer to rest, but if I am going to create a new post, as I already told you, not now. I prefer that it stays like this.