Hey guys, Im making a 2d platformer shooter where you shoot fireballs. Got the character and shooting animation done, but I need help on animating the actual projectile. Should I make another Animation Controller? Or do this on the actual player controller? Havent really found any tutorials covering this, just the basic of movement, shoot, etc. This is the code for shooting:
if (Input.GetKeyDown(KeyCode.F) && Time.time > nextFire)
{
nextFire = Time.time + fireRate;
anim.SetTrigger("isShooting");
Invoke("fireProjectile", 0.5f);
}
void fireProjectile()
{
GameObject clone;
clone = Instantiate(projectile);
clone.transform.SetParent(projCheck.transform);
clone.transform.localPosition = Vector3.zero;
if (!facingRight)
{
projCheck.transform.localPosition = new Vector2(-0.3f, -0.03f);
clone.transform.localScale = new Vector3(-5.01f,4.13f);
clone.GetComponent<Rigidbody2D>().velocity = -transform.right * projSpeed;
}
else if (facingRight)
{
projCheck.transform.localPosition = new Vector2(0.3f, -0.03f);
clone.GetComponent<Rigidbody2D>().velocity = transform.right * projSpeed;
}
}