# Triple-Shot Behavior (Angle Problem) [SOLVED]

I’m creating an enemy that will shoot bullet to the position of the player.

It is a triple-shot and the middle bullet is set to directly go to the player’s position and the two bullets on the side will be -45 and +45 of the player’s position.

This was done by storing the player’s x and y position and bullet angle +45 to change the angle of the 3 bullets. (-45, 0 45)

The problem is that when my player is in the upper left side, the bullets looks like this:

I think it’s because the angle in upper left is 0 so I guess that’s the problem because when the player is in the upper right, lower left, and right, it works fine. Hope someone can help me with this, thanks in advance!

You haven’t included all necessary screen snips. How are you determining the angle of each Bulletenemy created? How is each BulletEnemy moved?

In the one you’ve given, you create the BulletEnemy, then change variables BulletAngle, PlayerX and PlayerY of BirdEnemyYellowGreen but never use those variables. When you link BirdEnemtYellowGreen, to BulletEnemy, it doesn’t store the angle to bullet is being fired at for each BulletEnemy.

You should be storing BulletAngle in BulletEnemy. Each angle is unique to a BulletEnemy. The angle of one BulletEnemy is not the same as the other 2 you create.

1 Like

Oh, I forgot to open the event under the link part.
It’s Condition = Take into account Link objects then the events are add force to bullet by the Variable PlayerX + BulletAngle and Variable PlayerY + BulletAngle. It works fine but when the Player is in the upperleft, the bullets are only in one angle just like in the picture.

Can you screen snip the subevent? I realise you’ve described it, but it’s rather vague. Which object are you checking for a link, and in what order?

I’m guessing it’s BulletEnemy and BirdEnemyYellowGreen - in which case the “take into account all linked…” is unnecessary. You’ve already got the BulletEnemy and BirdEnemyYellowGreen from the parent event.

And how are you determining the initial value of BulletAngle?

1 Like

So basically, I get Player X and Y position and store it to PlayerX and PlayerY Variable. Then, I will declare it to the BulletEnemy to add force using those variables to make the bullet go to the Player. In addition to that, to make it shoots 3 times I put repeat then add BulletAngle to the equation (PlayerX + BulletAngle) to make the 3 bullets be in a cone like attack just like in the picture and the BulletAngle value will looks like (-45, 0, 45) + PlayerX and PlayerY.

How do you calculate BulletAngle? Is it meant to be from the enemy to the player?

That subevent condition (Find all linked obejcts…) is not needed. You’ve already got the unique bullet and enemy.

And it is wrong to add an angle to the X and Y co-ordinates. It may appear to work in some instances, but it’s not the right thing to do - you’re mixing polar co-ordinates with angles. And that’s asking for problems.

Instead you should be using “Add a force (angle)” for each bullet. Get the angle from enemy to player (pseudo-code : `BulletAngle = (AngleBetweenPositions(Player.X(), Player.Y(), Enemy.X(), Enemy.Y()) - 45`) before the repeat 3 times event block.

1 Like

Instead of using XPos and YPos of Player, I use the Angle of the Enemy to the Player and it works fine now! Thank you so much!