Selecting only the created object?

0 favourites
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • In my game, I use the following series of actions to fire bullets (both the player and enemies):

    (Object) spawn Bullet

    Set angle toward target (either player or current direction)

    Set damage...

    The trouble is, the Set angle action doesn't seem to care which bullets it chooses. For example, one enemy that shoots bullets aimed at you will aim all bullets on screen at you every time it shoots. How do I make it only select the shot it just fired?

  • Your code is probably deficient. Is the "set angle" within the "spawn bullet" command or just beneath it? If it's within, than just the most recently spawned bullet will be affected. Post a .capx if you're not sure.

  • It's below. How do I make it within? It can't be in the bullet's "On create" because different enemies fire bullets differently. I could make several different bullet objects, but I'd rather not if I don't have to.

  • One way would be to create a function that is called by different good guys, bad guys, whoever is doing the shooting. Bottomline, you have to place the "set angle" within the "spawn" part so that only the "spawned" bullet will be affected. Otherwise, your game will think that you want to do that to every bullet.

  • But how do you put the "set angle" part within the "spawn" part? I currently have it immediately below in the same event.

  • There appears to be common confusion here.

    Events pick objects, narrowing down a selected object list (SOL), and then the actions will be performed only on those objects.

    However, the System Create Object action will apparently also pick objects, specifically the object it just created. So, if you properly placed a create object bullet action right before your set angle bullet action, then it should only apply to that created object.

  • Hey Moscow,

    Post your cap.x, if it is in the same event it should work.

  • However, the System Create Object action will apparently also pick objects, specifically the object it just created. So, if you properly placed a create object bullet action right before your set angle bullet action, then it should only apply to that created object.

    That's what I thought, too, but it doesn't work for me.

    You can see my CAPX file at https://www.dropbox.com/s/n4ugzwygz346xqk/CiS2.capx, event sheet "Common enemies", groups "Copter" and "Tank", and also sheet "Global", group "Gun". In the preview mode, enemy bullets re-aim at you and occasionally (not always) your gun turns enemy shots around too.

    Edit: I'm spawning the bullets with Enemy->"Spawn another object".

  • Damn, well I did download it but I don't have the pause plugin so I cant open it up.

    Here is an example that should help.

    db.tt/6JXVzFom

    If this is already what you are doing then the problem lies somewhere else.

  • Yeah, mine is set up the same way as yours.

    Here's my .capx, minus the Pause and Function objects: dl.dropboxusercontent.com/u/811222/temp/CiS2NoPause.capx

  • Yeah, mine is set up the same way as yours.

    Here's my .capx, minus the Pause and Function objects: dl.dropboxusercontent.com/u/811222/temp/CiS2NoPause.capx

    I get a 404 error, not file not found.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oops, didn't finish uploading before I shut my computer. Should work now.

  • Sorry, but it the program says I cannot open it because it was saved in r133 or more recent. As far as I can tell r132 is the newest free version available.

  • r133 is a beta release and not stable. but it is still a release. I don't work with beta releases unless it's really mandatory feature.

    However, in the mean time if someone with r133 doesn't take a look. maybe link a picture. If someone with r133 doesn't solve it soon :P

  • I just updated because GenkiGenga's example was made in r133. UGH.

    I'm still pretty clueless on this problem. HALP.

    Edit: Wow! Found the problem. The bullets were being created to an invalid layer, so the game must have picked all bullets instead of the non-existent not-actually-created ones.

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