Hi guys here’s the thing i want may character to do attack animation so the scenario is im using now is i have 2 scrip the 1st scrip is for the power meter bar that continuously go up and down and it will stop once mouse is click,
2nd scrip is for my character animation once click my character will do attack animation.
both scrip is working well, but i want to change the scenario instead of attack animation by mouse click, what i want is may character will do the attack animation if my power meter bar hit the exact spot
here is my power meter code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LineMove: MonoBehaviour
{
bool upOrDown = true; //whether we are moving up or down
bool stopped = false; //whether we have stopped or not
public float upSpeed; //our upwards movement speed
public float downSpeed; //our downwards movement speed
public float maxHeight; //the max height at which we will change direction
public float minHeight; //the min height at which we will change direction
public float minWinHeight; //the minimum height we must be at to win
public float maxWinHeight; //the maximum height we must be at to win
void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse0))
{ //if the mouse is clicked
stopped = true; //then stop
Stopped();
}
if (!stopped)
{ //if we haven't stopped
MoveUpDown(); //move line
}
}
void MoveUpDown()
{
if (upOrDown)
{ //if we are moving up
transform.Translate(Vector3.up * upSpeed); //move up
if (transform.position.y > maxHeight)
{ //if we are at the max height
upOrDown = false; //switch to moving down
}
}
else
{ //if we are moving down
transform.Translate(Vector3.up * -downSpeed); //move down
if (transform.position.y < minHeight)
{ //if we are at the min height
upOrDown = true; //switch to moving up
}
}
}
void Stopped() //when we have stopped
{
if (transform.position.y > minWinHeight && transform.position.y < maxWinHeight)
{
Debug.Log("YOU WIN!!!"); //if line is between win min and max height we win or lose
}
else
{
Debug.Log("YOU LOSE");
}
}
}
and here is my attack animation
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimatorXD : MonoBehaviour
{
private Animator anim;
void Start()
{
anim = GetComponent<Animator>();
}
void Update()
{
if (Input.GetKey(KeyCode.Mouse0))
{
anim.SetBool(“isAttack”, true);
}
else
{
anim.SetBool(“isAttack”, false);
}
}
}