How do I: bullet spread with mirroring?

0 favourites
  • 9 posts
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • 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!

  • 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.

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

    http://www.filedropper.com/cannonprojectile

    Hope this helps glitchyghost !

    Regards,

    Gideon

  • 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!

  • 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.

  • 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!

    My bad...

  • Well, glad to hear Z-Order's working as it should then ^^

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)