Find and use the UID of objects?

For questions about using Classic.

Post » Fri Sep 19, 2008 12:19 pm

How would you go about finding an instance of an object that isnt directly affected by say, a bullet?
Dont want to destroy every enemy when only one gets shot.
B
2
G
4
Posts: 23
Reputation: 1,096

Post » Fri Sep 19, 2008 1:48 pm

You don't need to worry about it. Just do this:

[code:3gfu3e9d]
+enemy.sprite is overlapping bullet.sprite
-Destroy enemy.sprite
[/code:3gfu3e9d]

Instance picking is handled for you. Only the instances that meet the criteria of your conditions are selected for the actions that are in the event. If all of your enemies are dying when only one is hit by a bullet, check the logic of your conditions to make sure you're not picking more than you need to.

If you're still having trouble, post your .cap so someone can take a look.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Sep 19, 2008 2:38 pm

[quote="deadeye":3kbtr5mq]You don't need to worry about it. Just do this:

[code:3kbtr5mq]
+enemy.sprite is overlapping bullet.sprite
-Destroy enemy.sprite
[/code:3kbtr5mq]

Instance picking is handled for you. Only the instances that meet the criteria of your conditions are selected for the actions that are in the event. If all of your enemies are dying when only one is hit by a bullet, check the logic of your conditions to make sure you're not picking more than you need to.

If you're still having trouble, post your .cap so someone can take a look.[/quote:3kbtr5mq]

Well, that I know. What Im asking is rather this: Object A(uid 54) is being shot by Object B (uid 43)(bullet), but instead of Object A being destroyed, I would like Object C (uid 86)to be.

Would be usefull when you are using another object for collision checking.

Edit:
B
2
G
4
Posts: 23
Reputation: 1,096

Post » Fri Sep 19, 2008 2:51 pm

You can use containers for this, so that when one object is picked via conditions, another one (or more) is too.

Here's an article on it:
http://69.24.73.172/scirra/wiki/index.p ... Containers
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Fri Sep 19, 2008 3:31 pm

[quote="Rich":209x6mut]You can use containers for this, so that when one object is picked via conditions, another one (or more) is too.

Here's an article on it:
http://69.24.73.172/scirra/wiki/index.p ... Containers[/quote:209x6mut]

Exactly what Im looking for. Thanks =)
B
2
G
4
Posts: 23
Reputation: 1,096

Post » Fri Sep 19, 2008 3:32 pm

[quote="Jonaw":2qomgtyx]Well, that I know. What Im asking is rather this: Object A(uid 54) is being shot by Object B (uid 43)(bullet), but instead of Object A being destroyed, I would like Object C (uid 86)to be.

Would be usefull when you are using another object for collision checking.

Edit:[/quote:2qomgtyx]

Ah, see. That's a little more specific.

[quote="Rich":2qomgtyx]You can use containers for this, so that when one object is picked via conditions, another one (or more) is too.

Here's an article on it:
http://69.24.73.172/scirra/wiki/index.p ... Containers[/quote:2qomgtyx]

Dude, I totally forgot I even wrote that article.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Sep 19, 2008 11:16 pm

do you guys think containers can work for bullets? basically, i have bullets spawn from a character, and then particle effects spawn on that bullet. getting the particle effects to destroy themselves when their bullet is destroyed was a little tricky, and my current implementation is a bit wonky. at the end of the container article, it mentions having the same number of objects etc -- but being a bullet, there's only one instance of it in the layout editor (and is destroyed on start). i tried it out and it did NOT work as intended...

edit: if you test for a collision between a sprite and a particle effect, it lets you -- but the other way around isn't permitted... this seems to be related to my problem. i tried just setting it to where the same colision detection for the missle would also be checked for the particle effect spewer, but it destroys all instances of the particle effect spewer, and not just the one overlapping the sprite.

maybe a bug?
B
2
S
2
G
4
Posts: 254
Reputation: 1,958

Post » Sat Sep 20, 2008 1:55 am

Sounds a little strange. Maybe upload your .cap so someone can have a look?
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Sep 20, 2008 2:24 am

http://upload.dfyb.net/uploaded/messed_particles.zip

best solution i've found so far is to give the particle spewers a lifespan -- keeps them below a certain threshold. but the uploaded .cap doesn't have that -- the uploaded .cap shows how trying to destroy one particle effect spewer results in destroying all of them.
B
2
S
2
G
4
Posts: 254
Reputation: 1,958

Post » Sat Sep 20, 2008 3:36 am

Dude, you've really got to name your objects. My brain hurts from trying to read your events. It's all Sprite, Sprite2, Sprite3, Particles, Particles2, Particles3, and none of your sprite icons look like their sprites. :?

Anyway, I'm pretty sure I've got it fixed for you.

http://www.fileshack.us/get_file.php?id ... ticles.cap

I put the bullet-trails particle object into a container with the bullet, and removed (or rather, turned off) two of your events, particle spawn and particle create. I commented both. Seems to work fine now.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests