Which method is more correct to perform a one-time action to overlap with an object?

0 favourites
  • 3 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Hi everyone, I have some doubts regarding the correct use of "trigger once while true" in a situation like the one in my example. Basically, if I am not mistaken, if I need to do something only once when an overlap occurs between two objects, I am forced to use "trigger once while true". Reading various posts on the forum, however, I seem to have understood that it is better not to use it.

    If I use method 1 instead of method 2, is that more correct? And how can I get the result of method 1 without using the collision as a trigger event, which in some cases (for example when my objects use solid behavior or physics) can create other problems that are more complex for me to solve? I would have managed all the logic with variables, but in this case I was unable to get the desired result as construct continues to execute the code indefinitely. I hope I have explained myself well despite the use of google translate.

    Thanks to all those who will participate in the discussion.

    Link to the Project: https://mega.nz/file/maRkyJzR#B0tjnsuupItCpxaaxd4VUN3OvPnwHa95_CxG7B3WY0s

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You didn't really say the purpose of the overlap but since you are using drag and drop and I am imagining some kind of crafting mechanic, you can add 'on drop' so it's a trigger once to the overlapping conditions. If you grab the UID of the item you picked up you can compare the other item that is overlapping with it 'on drop'.

  • The method you suggest works.

    For my example, in fact, I took a cue from an inventory template I'm working on. But probably my example is wrong because I didn't think that with on drop the problem is solved.

    With my question basically I wanted to understand if it is true that the use of "Trigger once while true" (in a situation like the one in the example) is:

    1) absolute evil and is to be avoided always and in any case, otherwise I could commit a crime punishable with humiliation and torture by more capable programmers than me.

    2) they are just rumors and I can therefore simplify my life and use it if necessary without worrying too much that nothing breaks out.

    3) it is only a matter of elegance to be able not to use it, but if necessary even the good ones use it

    Anyway thanks for the answer Lionz, if it had been a real problem as always you would have guessed the solution even despite the problem explained wrongly.

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