Selecting only the created object?

Get help using Construct 2

Post » Sat Jun 08, 2013 1:48 am

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?
B
9
S
1
Posts: 98
Reputation: 853

Post » Sat Jun 08, 2013 2:26 am

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.
B
10
S
3
Posts: 102
Reputation: 1,888

Post » Sat Jun 08, 2013 2:48 am

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.
B
9
S
1
Posts: 98
Reputation: 853

Post » Sat Jun 08, 2013 3:10 am

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.
B
10
S
3
Posts: 102
Reputation: 1,888

Post » Sat Jun 08, 2013 4:12 am

But how do you put the "set angle" part within the "spawn" part? I currently have it immediately below in the same event.
B
9
S
1
Posts: 98
Reputation: 853

Post » Sat Jun 08, 2013 4:18 am

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.

B
11
S
2
Posts: 55
Reputation: 807

Post » Sat Jun 08, 2013 4:42 am

Hey Moscow,

Post your cap.x, if it is in the same event it should work.
ImageImage
B
123
S
23
G
7
Posts: 1,071
Reputation: 13,091

Post » Sat Jun 08, 2013 6:12 am

[QUOTE=CannedEssence]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.[/QUOTE]

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".MoscowModder2013-06-08 06:16:36
B
9
S
1
Posts: 98
Reputation: 853

Post » Sat Jun 08, 2013 6:47 am

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.

http://db.tt/6JXVzFom

If this is already what you are doing then the problem lies somewhere else.
ImageImage
B
123
S
23
G
7
Posts: 1,071
Reputation: 13,091

Post » Sat Jun 08, 2013 10:03 pm

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

Here's my .capx, minus the Pause and Function objects: https://dl.dropboxusercontent.com/u/811222/temp/CiS2NoPause.capx
B
9
S
1
Posts: 98
Reputation: 853

Next

Return to How do I....?

Who is online

Users browsing this forum: 25games, Google [Bot], missile, oosyrag and 32 guests