My turret is shooting at the origin point of it's target

Get help using Construct 2

Post » Sun Feb 26, 2017 12:50 pm

Any way to change that? :?:
B
10
S
4
Posts: 34
Reputation: 874

Post » Sun Feb 26, 2017 12:58 pm

Sure. You're modelling a weapon that has 0 spread, essentially. Just add a random amount to the angle of the bullet to represent the spread of the weapon :)
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Sun Feb 26, 2017 2:11 pm

You can add a random spread to the bullet or add sine to the enemy which makes it tougher to hit the target.

I use sine for a lot of enemies as it creates a more natural AI.
Banned User
B
27
S
7
G
58
Posts: 1,229
Reputation: 34,790

Post » Sun Feb 26, 2017 3:07 pm

lamar wrote:You can add a random spread to the bullet or add sine to the enemy which makes it tougher to hit the target.

I use sine for a lot of enemies as it creates a more natural AI.



How do I add a random spread to the bullet?

I tried:
On Bullet created -> Set Bullet angle of motion to Bullet.Bullet.AngleOfMotion + round(random(-20,20))

but it doesn't work
B
10
S
4
Posts: 34
Reputation: 874

Post » Sun Feb 26, 2017 3:31 pm

When you say it doesn't work what is it doing when you run that event?

If you are using 360 degree rotations you will need to determine if bullet is at 0 degrees or subtracting 20 from 0 will not give you the right degree.

Add bullet angle >20 and it should work.
Banned User
B
27
S
7
G
58
Posts: 1,229
Reputation: 34,790

Post » Sun Feb 26, 2017 3:57 pm

lamar wrote:When you say it doesn't work what is it doing when you run that event?

If you are using 360 degree rotations you will need to determine if bullet is at 0 degrees or subtracting 20 from 0 will not give you the right degree.

Add bullet angle >20 and it should work.


Whatever I do, the bullet still shoots at the exact position of the origin point, every single time...

http://imgur.com/a/WVUB6
B
10
S
4
Posts: 34
Reputation: 874

Post » Sun Feb 26, 2017 4:19 pm

Turaco wrote:
lamar wrote:When you say it doesn't work what is it doing when you run that event?

If you are using 360 degree rotations you will need to determine if bullet is at 0 degrees or subtracting 20 from 0 will not give you the right degree.

Add bullet angle >20 and it should work.


Whatever I do, the bullet still shoots at the exact position of the origin point, every single time...

http://imgur.com/a/WVUB6


Try setting the bullet to the angle the turret is facing and add in your random spread

Set bullet angle to turret facing angle+random(-20,20)
Turret facing angle >20
Banned User
B
27
S
7
G
58
Posts: 1,229
Reputation: 34,790

Post » Sun Feb 26, 2017 4:34 pm

lamar wrote:
Try setting the bullet to the angle the turret is facing and add in your random spread

Set bullet angle to turret facing angle+random(-20,20)
Turret facing angle >20



I tried setting the bullet angleofmotion to static 50 degrees. It changed nothing, the bullet still fired to its target


Edit: I found out that if a bullet has no speed itself, it will only move in the angle the turret is shooting. So what I did was change the angle of turret by -10 to 10 degrees at the moment its shooting. it looks funny, kinda like recoil. But I like it.
B
10
S
4
Posts: 34
Reputation: 874

Post » Sun Feb 26, 2017 5:13 pm

Turaco wrote:
lamar wrote:
Try setting the bullet to the angle the turret is facing and add in your random spread

Set bullet angle to turret facing angle+random(-20,20)
Turret facing angle >20



I tried setting the bullet angleofmotion to static 50 degrees. It changed nothing, the bullet still fired to its target


Edit: I found out that if a bullet has no speed itself, it will only move in the angle the turret is shooting. So what I did was change the angle of turret by -10 to 10 degrees at the moment its shooting. it looks funny, kinda like recoil. But I like it.


That s basically the same as adding random spread to the bullet just using the turret angle instead.

Glad you got it figured out!
Banned User
B
27
S
7
G
58
Posts: 1,229
Reputation: 34,790

Post » Sun Feb 26, 2017 5:32 pm

lamar wrote:
Turaco wrote:
lamar wrote:
Try setting the bullet to the angle the turret is facing and add in your random spread

Set bullet angle to turret facing angle+random(-20,20)
Turret facing angle >20



I tried setting the bullet angleofmotion to static 50 degrees. It changed nothing, the bullet still fired to its target


Edit: I found out that if a bullet has no speed itself, it will only move in the angle the turret is shooting. So what I did was change the angle of turret by -10 to 10 degrees at the moment its shooting. it looks funny, kinda like recoil. But I like it.


That s basically the same as adding random spread to the bullet just using the turret angle instead.

Glad you got it figured out!


Thank you for helping me :)
B
10
S
4
Posts: 34
Reputation: 874


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, MadSpy, MaxxMunnn, oosyrag and 28 guests