Code a shotgun?

Get help using Construct 2

Post » Fri Oct 18, 2013 3:26 pm

Hi,

I tried creating an enemy last week that would fire a burst of projectiles, each of which would have its angle deviated slightly. It didn't work. How do you do it? I tried spawning multiple bullets in the same event and modifying the angle of each, but that didn't seem to do it. Thanks!
B
17
S
4
G
4
Posts: 143
Reputation: 4,004

Post » Fri Oct 18, 2013 3:35 pm

something like this?

bullet on created set angle : bullet.angle+random(-5,5)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Oct 18, 2013 3:38 pm

Exactly.

Here's a capx:
http://www.doomsday-machine.com/stuff/shotgun_blast.capx

Touch/Click anywhere to trigger a blast to the left.
B
75
S
28
G
32
Posts: 481
Reputation: 19,713

Post » Fri Oct 18, 2013 4:37 pm

You could try this, if you want to have more control:


More random means more randomly distributed over the spread. 0 means equal distribution over the angles, 1 means completely random over the spread angle.
Of course you can also load instance variables instead of using local variables for spread, randomness and projectiles (not for a though).mindfaQ2013-10-18 16:40:47
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Thu Apr 24, 2014 11:42 pm

mindfaQ wrote:You could try this, if you want to have more control:


More random means more randomly distributed over the spread. 0 means equal distribution over the angles, 1 means completely random over the spread angle.
Of course you can also load instance variables instead of using local variables for spread, randomness and projectiles (not for a though).mindfaQ2013-10-18 16:40:47


This is great! I'm going to implement this.
B
13
S
5
G
1
Posts: 119
Reputation: 2,292


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, duditon, shinkan, trance and 8 guests