dop2000's Forum Posts

  • if we do the same for “round”, this method also shows itself well.

    Yes. But floor(random(0,6)) is easier to type and understand than round(random(-0.5,5.5))

  • choose(0,1,2,3,4,5) = round(random(0,5))

    igortyhon

    No, that’s not correct. The correct expression is int(random(0,6))

    choose(0,1,2,3,4,5) = int(random(0,6))

    Using round(random(0,5)) skews the distribution — both the lowest and highest numbers in the range will have a 50% lower chance of appearing compared to the others.

    See this demo:

    dropbox.com/scl/fi/kpnbq43gc6786r9blg7xn/RandomDemo.capx

  • Can you show your code, or share the project file?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In most cases, you don’t need For Each because the engine automatically loops through instances. For example,

    Enemy: Set HP to random(50,100)

    This will assign random HP values to each enemy instance, not the same value to all.

    However, you do need For Each if you specifically need to process each instance separately. For example:

    For Each Enemy → Call Function DealDamage(Enemy.UID)

    Without For Each, the function would only be called once for the first enemy instance.

    Another interesting fact I only recently learned: when multiple objects with multiple instances are referenced in the same event, the engine tries to process them in pairs.

    For instance:

    Enemy: Set size to Box.size

    This works fine if there’s only one Enemy or one Box. But if there are multiple instances of both, the engine will match them like this:

    • Enemy(0) → Box(0)
    • Enemy(1) → Box(1)
    • Enemy(2) → Box(2)

    Once it runs out of Box instances, it loops back to the beginning, meaning Enemy(15) might get Box(0)’s size.

    To avoid this, you’d need a For Each loop or another way to pick the correct instances.

    .

    Here’s a more obscure example of the same issue. Since the "On Timer" event picks both Tree instances, the engine compares Leaf.treeID with Tree.ID in pairs. As a result, some of the leaves are not picked.

    A "For Each Tree" loop is needed here:

  • So far, I have found this method: dividing time by tickCount. It seems much more stable.

    For what purpose? Where do you use this value?

  • Hi Tom,

    There's no notification again.

  • which is to add "Simulate at angle" to 8 Direction movement.

    You don't need it, because there are "Set vector X/Y" actions. You can set it directly to gamepad axis values:

    Player Set vector X to Gamepad.axis(0,0)
    Player Set vector Y to Gamepad.axis(0,1)
    

    Or calculate stick angle and distance:

    set a to angle(0,0, Gamepad.axis(0,0), Gamepad.axis(0,1))
    set d to distance(0,0, Gamepad.axis(0,0), Gamepad.axis(0,1))
    

    Then use these formulas to move the character:

    Set vector X to cos(a)*d
    Set vector Y to sin(a)*d
    
  • I tried, for me it's making a random card for each one instead of the exact card.

    Do you have each card in a separate sprite, and all sprites added to a family?

    10k objects doesn't seem like a good idea. I would suggest having all cards in one sprite as animations.

    If you prefer different objects, then use "Create object by name" action to create a particular card.

  • Something like this I guess (if I understand the task correctly):

    Player on collision with enemy
    -> Player set speed to 25
    -> Player start timer "reset_speed" for 0.5
    
    
    Player is overlapping slime
    -> Player set speed to 25
    -> Player start timer "reset_speed" for 0.5
    
    Player on timer "reset_speed" 
    -> Player set speed to 50
    
  • No... I thought your array contained words? Why do you clear it?

    See this example:

    dropbox.com/scl/fi/zemsgxz3r9f8gq6164ocu/ArrayPermutationExample.c3p

  • Use permutation table feature of the AdvancedRandom plugin.

    AdvancedRandom create permutation table with size Array.width
    

    The first random word would be Array.at(AdvancedRandom.permutation(0))

    The next word Array.at(AdvancedRandom.permutation(1))

    And so on. They won't repeat.

  • I'm not a fan of "trigger once" condition, don't use it if there are multiple instances of objects that could be overlapping.

    I suggest using timers instead of "wait" action, because you can't cancel or extend the wait if objects collided again within 0.5s

  • So you need to arrange them in a grid, like an inventory? There are plenty of examples of how to do this.

    Here is a simple loop:

    Result:

  • fisholith Oh, I'm sorry, my mistake. It's just at the first glance your comment looked very similar to what ChatGPT generates when I ask it programming questions. I can see now that it's not, apologies again.

    Although I don't understand why your proposed solution is in Javascript. It's clear from the OP's post that they are using the event system.