Undestanding Picking

0 favourites
  • 3 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • Hey there, I ve got some questions about picking.

    Triggers - If I set a trigger on some condition, will the code be aplied only the the instance, which fulfilled the condition (will be picked only the instance which caused the trigger)?

    For each - Generally, when you want apply a code for every instance of a Type in several programming languages (no idea about HTML), you'd use "For each" or another loop. What is the difference between For each Object set variable to 0 and Pick all Object set variable to 0? Is there a difference in performance?

    I already know, that "For each" pretty much picks one instance by one and applies the code individually, which can be actually better for the game designer's purposes, but there's a problem - C2 will not let you create triggers in loops, which is quite understadable as trigger is something to be called only in certain conditions. However there are also rather conviniet fake triggers, that are not really triggers, because they are evaluated every tick. My problem is - if I start the code for a certain Type with For each-, so I could spare myself trouble with Picking deeper in the code, I will not be able make conditions, that would prevent pointless evaluations for fake triggers.

    Would the devs consider allowing fake triggers in loops? Also, it would be great to point out, which triggers are actually fake (Trigger once while true and collisions are obvious, but what about On animation "" finished)?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Actually most picking condition will make it so the rest is applied to every incstance already, but in some specific cases, that is not the case (I think the On timer condition is one of them), in those cases, adding a for each loop is mandatory, also a trigger happens first, always, but in the cases I saw (like the on timer), the loop can be done after the trigger and it will work just fine (the for each applies to every picked instances, so the trigger may pick instances, but the loop after will apply that to every concerned instances).

    Also trigger once is not a good idea after loops, since it will be true for the first cycle of the loop only, however, the other way around may work.

  • Also, it would be great to point out, which triggers are actually fake (Trigger once while true and collisions are obvious, but what about On animation "" finished)?

    You can spot triggers by the Green arrow (If I understand what you mean correctly). For instant "On Mouse click" is a trigger and will trigger whenever you click.

    On animation finished is a trigger. Some ought to be triggers in my opinion, but ain't for some unknown reason. For instant Video ended is not a trigger, but would make sense if it was.

    [quote:2xvwkt1x]For each - Generally, when you want apply a code for every instance of a Type in several programming languages (no idea about HTML), you'd use "For each" or another loop. What is the difference between For each Object set variable to 0 and Pick all Object set variable to 0? Is there a difference in performance?

    I don't think there are any performance difference between them and if there is. I doubt its worth worrying about.

    Pick all is something that is often misunderstood, you don't actually need it in 95% of the case as C2 will do that automatically.

    To use pick all correctly imagine something like this:

    ->Bullet hit enemy   (In this case you have picked a bullet and an enemy)
    
    Imagine that you wanted to damage all other enemies as well, if the enemy dies from the hit.
    Since you have already picked an enemy you need to reset the picking, which you can do with a "Pick all Enemy" in a sub event. Which will then allow you to apply damage to those. So you don't have to split up your events etc. 
    [/code:2xvwkt1x]
    
    For each is pretty much as you stated and used whenever you want to work with a group of objects but still as individuals.
    
    [quote:2xvwkt1x]but there's a problem - C2 will not let you create triggers in loops, which is quite understadable as trigger is something to be called only in certain conditions. However there are also rather conviniet fake triggers, that are not really triggers, because they are evaluated every tick. 
    
    Im not sure if it would actually make any sense if triggers worked inside loops. I would assume its because you might organize your things a bit wrong then instead. 
    As with the "On mouse click" it would be a bit strange to put it in a loop. because it needs to trigger whenever you press the mouse button and not during the loop. But might have misunderstood you depending what you are referring to.  
    
    [quote:2xvwkt1x]My problem is - if I start the code for a certain Type with For each-, so I could spare myself trouble with Picking deeper in the code, I will not be able make conditions, that would prevent pointless evaluations for fake triggers.
    
    But you always want to pick as deep and precise as possible. It sounds a bit like you are confusing how triggers works. but maybe if you give an example of what you are trying to do, it might be easier to understand your problem.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)