How do I: bullet spread with mirroring?

Get help using Construct 2

Post » Fri Jul 24, 2015 1:31 am

I want to add a bullet spray. I know how to correctly mirror bullets/player normally.

I added a variable to the bullet called spreadFactor and set it to 5. I was pretty pleased with myself to figure out the following, using 'random' for bullets angle of motion:

Events/Action:
PlayerProjectile: Set Bullet Angle Of Motion to;
random(-playerProjectile.spreadFactor, playerProjectile.spreadfactor)

This nicely sprays the bullets when firing, adjusting the angle up and down.

However, when I face to the LEFT, the bullets spray (and shoot) to the right still. Despite my variables setup which state which way the Player is mirrored and facing 180 or 0.

I have tried (most) of the obvious, including reading the manual, mirroring/direction/flipping and experimenting with Object Angle Vs Bullet Angle, which have had mixed results - so please do check the CAPX

I am running beta 210. Would this matter? I have noticed a Z Order Bug in this version- mainly that its unusable now.

I have a feeling its something really obvious that I am going to kick myself for, just a bit off today, and I would be forever grateful to the person who can help.

Thanks!
B
7
Posts: 16
Reputation: 314

Post » Fri Jul 24, 2015 5:43 am

Hey @glitchyghost, :)

I think what may be happening is that the bullets are always being set to spread relative to the angle "0", but specifically the angle "0" relative to the world, instead of relative to the player.

Angle 0 always points to the right.
0 = Right
90 = Down
180 = Left
270 = Up
360 = Right


The second issue is that using the Mirror action on a sprite will change the orientation of it's image, but if I recall correctly, it won't change the sprite object's actual angle.

So you could try splitting the spread event into two events.

If player is NOT Mirrored: random( -playerProjectile.spreadFactor , playerProjectile.spreadfactor )
If player is Mirrored: 180 + random( -playerProjectile.spreadFactor , playerProjectile.spreadfactor )

When the player is Mirrored, you can add 180 to the angle so the bullets fire to the left, plus or minus a random spread factor.

Hope that helps out. :)
B
26
S
17
G
8
Posts: 323
Reputation: 6,021

Post » Fri Jul 24, 2015 5:50 am

Here's a .capx pretty much showing what @fisholith talks about:

http://www.filedropper.com/cannonprojectile

Hope this helps @glitchyghost !

Regards,
Gideon
B
10
S
1
Posts: 72
Reputation: 1,015

Post » Fri Jul 24, 2015 6:59 am

That worked! I was so close. I just added 180+ to the mirrored (direction = 180) random angle expression.. To others, either of the fixes are ok. And thanks for the explanation.

I find that the mirror function does work, as long as the 0 image point origin is set to the MIDDLE. Also using direction as a variable in conjunction works nice too.

I'd been staring at a crosshair with 270-0-90-180 written on it all day haha.

Thank you so much guys!

Also I must say a massive thanks to the Scirra Team - simply awesome software that you are no doubt extremely proud of. It has been life changing, seriously.

I can't wait for Construct 3 (I have to Bootcamp right now) and PLEASE keep it 2D!
B
7
Posts: 16
Reputation: 314

Post » Fri Jul 24, 2015 9:38 am

What do you mean about "Z Order Bug in this version- mainly that its unusable now" ?
Have you made a proper bug report following the guidelines ?

I used R210 during last week end for a game jam making heavy use of Z ordering and haven't had issues as far as I could tell.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,319
Reputation: 87,487

Post » Fri Jul 24, 2015 1:40 pm

Kyatric wrote:What do you mean about "Z Order Bug in this version- mainly that its unusable now" ?
Have you made a proper bug report following the guidelines ?

I used R210 during last week end for a game jam making heavy use of Z ordering and haven't had issues as far as I could tell.


Hi Kyatric, I'm glad you pulled me up on this- after trying to replicate the issue I was having, (couldn't seem to view more than one item in the order) today I realise that I wasn't clicking on the layout margin to access entire Z order list! :roll:

My bad...
B
7
Posts: 16
Reputation: 314

Post » Fri Jul 24, 2015 2:33 pm

Well, glad to hear Z-Order's working as it should then ^^
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,319
Reputation: 87,487

Post » Fri Jul 24, 2015 3:12 pm

Me too!
Whilst we're on the subject of 'potentially NOT bugs it's just me' ;) can you confirm that the 'replace' shortcut is working as it should? I could of sworn that when pressing R on ANY event condition or action, that the entire object menu should become available to switch out? Currently, I find around a 30-50% chance that the condition or action will allow a replace (unless it's me once again overlooking the full scope of that feature? thanks
B
7
Posts: 16
Reputation: 314

Post » Sun Aug 09, 2015 10:12 am

The replace feature, (as far as I know), has loosely two modes.

If there's only one object available to replace:
Pops up an object browser, and whatever you choose will replace the original object.

If there are two or more objects that can be replaced:
Pops up an object browser showing the objects that can be replaced, and whatever you choose will be designated as the object type to be replaced.
Then you will be presented with another object browser, and whatever you choose will replace the object designated on the previous step.
B
26
S
17
G
8
Posts: 323
Reputation: 6,021


Return to How do I....?

Who is online

Users browsing this forum: NN81, TsubaRu and 9 guests