How do I functions works with one object of various

Get help using Construct 2

Post » Tue Nov 03, 2015 12:35 pm

Sorry for the general title but i don't know how explain it.

I'm trying to use functions but seems i'm doing something wrong (https://www.scirra.com/manual/149/function)

I have a condition that says:
WHen bullet collides with wall -> Destroy and spawn a few particles.

So i can shoot 5 bullets and when each one collides with the walls the bullet is destroyed and the particles appears.

If i put the events on a function and call it from the condition if i shoot 5 times, every time that the bullet collides on the wall spawn particles on all the bullets that appears in the screen.

What i'm missing?
B
24
S
10
G
3
Posts: 553
Reputation: 4,483

Post » Tue Nov 03, 2015 1:00 pm

I "solved" the problem but not like it.

I added an instance variable on the bulled called: "Collide" that is 0 and 1 when impacts with the walls. On the function i added the condition "Shoot collide=1".

Works, but is ther any other form that can save this condition or another way to do that more simple?
Last edited by matriax on Tue Nov 03, 2015 2:04 pm, edited 1 time in total.
B
24
S
10
G
3
Posts: 553
Reputation: 4,483

Post » Tue Nov 03, 2015 1:07 pm

you could set a parameter to the bullet.uid when calling the function and use a pick by uid condition..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Nov 03, 2015 2:16 pm

Yes, i know, i guess you not saw but previous solution. Then for this case i have to use some parameter to identify.

I tried with "trigger once while true", "Repeat 1",etc... and other things but nothing, the only way i get this working is using the parameters.
B
24
S
10
G
3
Posts: 553
Reputation: 4,483

Post » Tue Nov 03, 2015 2:27 pm

matriax wrote:Yes, i know, i guess you not saw but previous solution. Then for this case i have to use some parameter to identify.

I tried with "trigger once while true", "Repeat 1",etc... and other things but nothing, the only way i get this working is using the parameters.


Actions are always executed on the instances picked in the events, Functions don't seem to keep the picked objects from the event they are called, so the correct instances should be re-picked..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Nov 03, 2015 6:55 pm

I see, thanks for the info!
B
24
S
10
G
3
Posts: 553
Reputation: 4,483

Post » Mon Nov 28, 2016 7:48 am

I'm actually having issues with this too now. Can anyone show an example of how picking the UID from the parameter is done? I can't see to get it to work properly.
B
93
S
33
G
11
Posts: 278
Reputation: 12,693

Post » Mon Nov 28, 2016 7:54 am

Actually just figured it out following this tutorial : https://www.scirra.com/tutorials/4843/p ... m-a-family
B
93
S
33
G
11
Posts: 278
Reputation: 12,693

Post » Mon Nov 28, 2016 11:46 am

LittleStain wrote:you could set a parameter to the bullet.uid when calling the function and use a pick by uid condition..


I think this is the best solution, simple and it should work fine.

if(bullet collides wall)
. .call funtion "destroy_bullet"(bullet.UID)

On function "destroy_bullet"
. .Bullet.Pick_instance _by_ID (Param(0))
. .bullet.destroy;
. .create object(particles at bullet.position)
B
6
S
2
Posts: 61
Reputation: 1,099


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, kellehk, ST314, Yahoo [Bot] and 24 guests