- Home /
Bullet fires before direction change
Hello everyone, I've been having this bug for the past week after I implemented 8 axis 2D shooting to my 2D game where if the player is looking right and then fires upwards, a bullet is wasted because it fires towards right (the next bullet shot goes upwards as it's supposed to). This can happen with any one of the axis (eg. looking up and then shooting down-right ect). The aiming and the shooting is handled all in the same script. The bullet spawn has an animation controller with 5 animations (I then flip the character to have the remaining 3 directions) that handle the visuals. Here's the script:
//Directional
for (int i = 0; i < combatAnim.Length; i++)
{
combatAnim[i].SetBool("DirU", U);
combatAnim[i].SetBool("DirUR", UR);
combatAnim[i].SetBool("DirR", R);
combatAnim[i].SetBool("DirDR", DR);
combatAnim[i].SetBool("DirD", D);
}
and I use this line of code for Instantiating:
clone = Instantiate(currentProjectile, spawnPos.position, spawnPos.parent.transform.rotation);
The parent of the bullet spawn is what has the animations for each axis.. I don't have any idea on how to solve this, because it's like the Instantiate happens before the animation starts (even if it looks like everything happens on the same frame)
Your answer
Follow this Question
Related Questions
Transform.translate bullets problem 0 Answers
Fire limit in a Space shooter? 1 Answer
Distribute terrain in zones 3 Answers
2d bullet shot at bullet emitter 0 Answers