Hello Im working on my first Unity project (2D Platformer) and I’ve stumbled into a problem where my left-click nor right-click is being detected/registered in unity.
The code is for an animation which left key is supposed to initiate (in void Update) :
private void Awake()
{
anim = GetComponent<Animator>();
playerMovement = GetComponent<PlayerMovement>();
}
private void Update()
{
if (Input.GetMouseButton(0) && cooldownTimer > attackCooldown && playerMovement.canAttack())
Attack();
cooldownTimer += Time.deltaTime;
}
private void Attack()
{
anim.SetTrigger("attack");
cooldownTimer = 0;
fireballs[FindFireball()].transform.position = firePoint.position;
fireballs[FindFireball()].GetComponent<Projectile>().SetDirection(Mathf.Sign(transform.localScale.x));
}
private int FindFireball()
{
for (int i = 0; i < fireballs.Length; i++)
{
if (!fireballs*.activeInHierarchy)*
return i;
}
return 0;
}
}
I’ve tried begug messages like
if (Input.GetMouseButton(0)) Debug.Log(“Pressed left click.”);
also when I use Debug message containing:
else(“Left key not pressed”);
I get no Feedback from the console.
Any help to solve the problem is very appreciated!