How do I functions works with one object of various

0 favourites
  • 9 posts
From the Asset Store
Human/Character Base Pixel Art Sprites in various poses (nearly 100 files)
  • 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?

  • 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?

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

  • 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.

  • 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 see, thanks for the info!

  • 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.

  • Actually just figured it out following this tutorial : https://www.scirra.com/tutorials/4843/p ... m-a-family

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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)

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