Like I said, Im trying to make gameObject move only if specific button is pressed, now the object moves every time i press a button that plays sound. I would like it to move only if specific button is pressed or specific sound is playing. I would really appreciate any help
Here is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StopButtonRotation : MonoBehaviour
{
public Rigidbody2D rigidBody2D;
public GameObject button;
void Start()
{
rigidBody2D = GetComponent<Rigidbody2D>();
rigidBody2D.rotation = -90f;
}
void FixedUpdate()
{
if (button.tag.Equals("Button2"))
{
if (Playsound.isPlaying)
{
if (rigidBody2D.rotation <= 0f)
{
rigidBody2D.rotation += 4.0f;
}
else
{
rigidBody2D.rotation += 0.0f;
}
}
else
{
rigidBody2D.rotation = -90f;
}
}
else
{
rigidBody2D.rotation = -90f;
}
}
}
I think the problem is with this line:
if (button.tag.Equals(βButton2β))