Bubble Bubble with unity
I'm recreating Bubble Bobble of 1986 with unity, but I came to a dead end, when I initialize my prefabs and run the code for shoot the bubble still in the start position, I tried on a few forums and tried some solutions including use "GetComponent .AddForce", but without success.
This is the code for the bubble:
public class Shoot : MonoBehaviour
{
public Vector2 DistShoot;
Animator animator;
void Start()
{
animator = GetComponent<Animator>();
}
void FixedUpdate()
{
if (Input.GetKeyDown(KeyCode.X))
{
GetComponent<Rigidbody2D>().AddForce(DistShoot, ForceMode2D.Impulse);
}
}
void Update ()
{
if (Input.GetKeyDown(KeyCode.X))
{
animator.SetBool("Shoot", true);
}
else
{
animator.SetBool("Shoot", false);
}
}
}
I'm a beginner, someone can help me suggesting a solution?
Comment