Why does my bullet function only originate at the first sprite spawned in layout?

0 favourites
  • 4 posts
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • I have 2 enemy sprite objects, both in the same family, sharing a number instance variable; 'Speed.' En_Red has a higher speed than En_Yellow.

    On start of layout, System creates En_Red. On the next line, System creates En_Yellow.

    I have a function created to fire a bullet, which creates the bullet object at enemyfamily.x, enemyfamily.y ...sort of.

    I get enemyfamily to pick the instance with the lowest speed (which should be En_Yellow) and then run the bullet function.

    Instead of the bullet originating at the enemy with the lowest speed, the bullet instead appears to be created at whichever 'create enemy' line happens to be above the other in the 'on start of layout' instruction.

    Why does that happen?

    If I add a 'set colour' instruction, I can confirm the family is indeed picking the instance with the least speed, yet the bullet still originates at the first enemy spawned in the layout, even if I swap the placement of the spawn lines back and forth.

    I'm really just trying to get my head around picking a specific instance within a family and having a bullet function originate from the instance I'm picking, but, well, you know... I'm a noob.

    Any help is appreciated, thanks folks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • functions don't know anything about what was picked outside of the function.

    so, in your event 5, pass the UID as a parameter to the function. then in the function pick the family member by its UID.

  • Well, there you have it. it works. Thank you AllanR!

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