How do you make a bullet sprite move towards a sprite?

Get help using Construct 2

Post » Fri Jul 29, 2016 10:44 am

I thaugth that you used the set angle Sprite.Angle to make a bullet sprite move towards a sprite but it still doesn't do that. It seems more like it moves in the Sprites angle rather then it's position if you use that. I tried using Sprite.X, Sprite.Y and both at the same time but the bullet sprite still doesn't move towards the player. It doesn't seem to be a Sprite.position in the Sprite.Angle options so how do you make it work? I know that the way you make a bullet sprite move towards the player is different depending on if it's not spawned from a sprite whit the turret behavior and if it is spawned from a sprite whit the turret behavior so i would want to know how you make it work whit both.
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Fri Jul 29, 2016 1:59 pm

Sprite > Bullet > Set angle of motion to angle(sprite.x,sprite.y,player.x,player.y)
Every tick if you want it to act as a kinda 'heatseaking' never missing bullet.
Once while true if you want to shoot at the place where the target is at the moment of shooting.

With turret, you just can use the predictive aim, this will alter the angle of the turret on the moment of shooting, and it will only work if the target keeps moving in the same direction at the same velocity. (and if the bullet is given the speed as given by the turret behavior)

If that is what you want. Fire the bullet straight to the place where the target will be in the future. Then indeed the most easy thing to do is use the turret.

Or calculate where the target will be in the future. With or without the help of this plugin. behavior-rex-interception_t178838
B
33
S
18
G
27
Posts: 2,447
Reputation: 20,358

Post » Fri Jul 29, 2016 2:35 pm

That answher is still not near to complete.

Got to start with the difference between 'system > create' and 'sprite spawn'.

Create just creates a sprite in a given position with the same angle as the first made instance in the layout.
Spawn creates a sprite at a given position and aligns the newly made sprite with the angle of the spawing sprite.
A turret 'spawns'.

So, using 'system create' you have to Set angle of motion (or the angle) towards a target, using one of the above methods. And you can steer the bullet on its way using same methods.

Using spawn, you can rotate the spawner towards the target, using one of the above methods. And you can steer the bullet during its way using same methods.

Right, now i hope it stands.
B
33
S
18
G
27
Posts: 2,447
Reputation: 20,358


Return to How do I....?

Who is online

Users browsing this forum: ivanski1983, marcoscodas, Yahoo [Bot] and 12 guests