Objects Group/De-Group using Trigger OR Static Motion Path OR Reset Motion Path Starting Point?

Hi Forum,

Imagine a spaceship (image object) that the user can move (left/right/up/down) with arrow keys.  Four simple triggers achieves this easily.

Now imagine getting this ship to "fire a bullet".  Although there are many ways to achieve this - I can't seem to crack it.  By adding a second image (the "bullet"), and grouping it with the space ship, it's easy to have it move around with the ship.  This allows it to fire from the current position of the space ship, moving up in a straight line (when the users presses space bar for example).

However - while the bullet is travelling upwards on it's motion path, if the user presses arrow keys to move the space ship, the trajectory of bullet also moves left/right with it.

How can I get the motion path to stay static in this scenario?

I tried using a true/false variable to report the current fire state.  Then for the movement triggers, I used the following conditions:

  • If firing state = true, then move the group (ship + bullet) when users presses key.
  • If firing state = false, then move only the ship (object within group).

However the bullet doesn't "shift back" to the ships new position after it's motion path completes, and the two (ship/bullet) become out of sync/position with each other as the ship moves around.

Any clues?

4 Replies
Richard Hill

Hi Simon, here's your answer. NO groups. Create variables called xposition and yposition set their default value to 0,0. ( this will be relative to your original ship position). You already know how far each left and right , up and down button push will move you.  Add or subtract 1 upon each press.  Then give it conditionals that when you press fire, AND xpostion is ==1, and Yposition == 2,  it loads a layer with your missile on it at  1,2.  You will need the one layer for each position your ship  will fire from.   It works, I've done it.   * to visually help you align you missles, place %xposition%, %yposition% on stage.

Richard Hill

The problem your having with that method, seems to stem from the way animations are executed.  They typically need to follow through before next execution.  When working with groups the outcome tends to be messy, and you can have many unexpected results.  For me it's a general rule of thumb not to mess with the individual positions of pre-grouped objects.  Well unless some someday comes out with a technical how-to.   I am curious if you're willing to tell, how are you hit targeting your collisions?