How do I scatter object instances at different angles?

0 favourites
  • 8 posts
From the Asset Store
112 High-Quality destruction sounds for videogames
  • Hi,

    I have an object that, upon a Touch event, is impulsed at angle away from the touch coords using Physics.

    I expected that, upon dragging a new instance of the same object to the Layout at a different position, the Touch even would impulse each instance at a different angle.

    What is happening though, is that both instances are being impulsed in parallel - using the same angle.

    How can I achieve the desired effect - having each instance calculate the impulse angle independently?

  • Replace the impulse angle that you are using with a range, you can use random(x,y) to select a value from a range, or choose(x,y,z) to select a random angle from a selection.

  • The thing is, I don't want a random scatter, I want the angle to be a push originating from the Touch position outwards.

    I don't think random() would help that, am I right?

    I have a Touch event, which gives me Touch.X and Touch.Y, and 2 instances of the same object, each on a distinct X and Y position.

    I tried to calculate:

    On Touch event: Apply Physics impulse 1 at angle: angle(Touch.X, Touch.Y, boss.X, boss.Y)

    But it does not consider the 2 instances of the boss Sprite independent X and Y coordinates, which is what I am aiming for.

    Please advise.

  • Rephrasing:

    I want to On Touch, For Each instance object of Sprite boss, to push it radially from the Touch tap coords.

    I already have an Event:

    On Touch For Each boss on boss: apply Physics impulse 1 at angle angle(Touch.X, Touch.Y, boss.X, boss.Y)

    My latest guess is that this is not the way , because the on boss might be picking only the first instance to calculate the angle (boss.X, boss.Y), but I can't figure out how to pick the chosen instance inside the loop.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The logic you've put there is correct so let's see the structure in the event sheet if it's not working

  • To answer my own question, in my project I had another solution to a previous problem (how to preserve constant linear speed after every collision bounce), that was made for a single object (boss). that used a single variable to store the angle. when increasing the number of objects, when rectifying the speed, it also changed the direction of all objects to a single one.

    I changed that part to work inside the For Each loop to account for multiple objects, and now it's working.

  • Ok great

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