# How do I get the bullets to aim in the right direction...

Get help using Construct 2

### » Mon May 02, 2016 10:36 pm

...without using the "set angle" action? I want to make sure this projectile stays at the same angle, but travel in the direction of another object.
B
30
S
14
G
6
Posts: 29
Reputation: 5,512

### » Tue May 03, 2016 9:12 am

Is that 'projectile' moved by a bullet behaviour or in another way?
How do you shoot it?
Is that 'another object' moving ? Is the 'projectile' allowed to mis ?
Is that 'projectile' allowed to align to its path or does it needs to keep the same angle ?

Most behaviours have a 'set angle' no/yes switch.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Tue May 03, 2016 10:27 am

Yes, it uses the Bullet behaviour. It's spawned by a boss, actually. The "other object" is the player, and it only sets its angle when it's first first.

What I'm trying to do is make it so it moves in the dir of the player, but the sprite itself doesn't rotate. It just looks weird when it does it.
B
30
S
14
G
6
Posts: 29
Reputation: 5,512

### » Tue May 03, 2016 11:06 am

Okay, so you want the bullet to change direction towards a moving player, so it wil always hit. Kinda like a heat-seaking-bullet.

Wel you have the bullet action 'set angle of motion'. That wil ask you for an angle.
The needed angle you get with an expression. Assuming that the name of the bullet = "bullet' and the name of the player = "player" it is:

angle(bullet.X,bullet.Y,player.X,player.Y)

Just fill that in the 'set angle of motion' action.

Basecaly you use the same tool to change angle as you use to do the motion. If you use 'rotate toward position' (by instance) you rotate the physics world, while you need to rotate things IN that physics world. You will make things go stuck by pushing them into solids, the paths will go erratic, in fact you just break the physics world.

A little warning; if the bullets always hit, the player goes erratic too.

Hope i helped.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Tue May 03, 2016 3:23 pm

99Instances2Go wrote:Okay, so you want the bullet to change direction towards a moving player, so it wil always hit. Kinda like a heat-seaking-bullet.

Wel you have the bullet action 'set angle of motion'. That wil ask you for an angle.
The needed angle you get with an expression. Assuming that the name of the bullet = "bullet' and the name of the player = "player" it is:

angle(bullet.X,bullet.Y,player.X,player.Y)

Just fill that in the 'set angle of motion' action.

Basecaly you use the same tool to change angle as you use to do the motion. If you use 'rotate toward position' (by instance) you rotate the physics world, while you need to rotate things IN that physics world. You will make things go stuck by pushing them into solids, the paths will go erratic, in fact you just break the physics world.

A little warning; if the bullets always hit, the player goes erratic too.

Hope i helped.

Thank you for the advice. I'm currently away at the moment, but I'll report back with results once I get the chance. Thanks!
B
30
S
14
G
6
Posts: 29
Reputation: 5,512

### » Tue May 03, 2016 11:23 pm

It works! Which is weird, because I swear I tried that before and it didn't work. Oh well, at least I got it up and running, so that's nice.
B
30
S
14
G
6
Posts: 29
Reputation: 5,512