I have a question about Function

0 favourites
  • 12 posts
  • First of all watch these events

    in the Actions only x position is changed, So instead of repeating all actions i created a function and put all actions there with parameter "pos" to change x position. but function not working there.

    My Question is why function needs conditions too, OR why function doesn't take conditions from where it is called.

    see below

    Tagged:

  • When you use actions the object instance to apply the actions to is already picked by the conditions, when you use functions the actions inside don't automatically pick the instance of the object from the previous conditions.

  • is correct

    The solution is to pass the objects' UID into the function as a parameter

    For example:

    Call myFunction (pos: 300, alphabetUID: alphabets.UID, dotsUID: dots.UID)

    myFunction

    Pick alphabets by UID: alphabetsUID

    Pick dots by UID: dotsUID

    (then do your actions)

  • Thanks you for your suggestion.

  • noah Gengo in the conditions there dots and steps have difference conditions on each event. pick by uid will not work here.

  • I am correct guys! luckyrawatlucky what's the problem? share a screenshot of the new events and where the issue is, thanks

  • all the conditions is picking multiple "dots" & "steps" that's why i can't use pick with UID in the function.

  • I know this but you didn't change anything? The guy above mentioned how to fix it. This appears to be the same screenshot from the first post so what did you try?

  • see condition of 3rd and 4th event

    dot | ID < gCurrent

    dot | ID > gCurrent

    in the function i can use either dot | ID < gCurrent OR dot | ID > gCurrent, i cannot use both on one function.

    Noah Gengo suggested to pick Dot and steps using UID inside function but by doing this function will pick only 1 object but dot | ID < gCurrent is picking multiple object.

  • Time to revert back to the basic events you had then :) no need for function. I think also if you are calling the function every tick then there isn't a need for it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No I'm not calling function every tick.

    Screenshot looks like I'm calling it every tick because i combined 2 screenshots together. There were some other events between them.

  • see condition of 3rd and 4th event

    dot | ID < gCurrent

    dot | ID > gCurrent

    in the function i can use either dot | ID < gCurrent OR dot | ID > gCurrent, i cannot use both on one function.

    Noah Gengo suggested to pick Dot and steps using UID inside function but by doing this function will pick only 1 object but dot | ID < gCurrent is picking multiple object.

    You can call functions for multiple objects. Just put a 'For Each' condition after you've picked your objects. This will call the function for each object

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