Range with Bullet Behaviour

This forum is currently in read-only mode.
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • 2 questions about an object with Bullet Behaviour:

    • in debug-mode the amount of pixels traveled can be seen. Can I use this information in events?

    (For example: after traveling 200 pixels, set speed to 20)

    • is there a known bug with exceeding range?

    It completely ignores the "on exceeding range"-event.

    Am I doing this wrong?

    (1 condition, 2 actions)

    Sprite A: On collision with Sprite B

    Sprite A: set bullet range to 210

    Sprite A: 'private variable' to 1

    (2 conditions, 1 action)

    Sprite A: 'private variable' equal to 1

    On exceeded range

    > Sprite A: set speed to 2

  • Object[Bullet].Travelled contains how far it's gone.

    On exceeded range should be there first condition in the second event.

  • Yeah, the 'travelled' expression in the bullet behavior retrieves its distance travelled.

    The range exceeded thing might be a bug, can you reproduce it in a new .cap?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Bug reported (artifact number 2789509) about influencing/changing the range (at runtime), with added cap.

    Object[Bullet].Travelled contains how far it's gone.

    Thanks, that's what I was looking for.

    Although one question arised quickly:

    1 object is making distance (bullet behaviour).

    After every set distance, carry out an action (for example, change direction).

    Object[Bullet].Travelled > 50

    Set angle to Object.Angle - 40

    Result: keeps spinning.

    I thought, that's logical, since the angle is changed, but it's still making distance, so it stays above 50.

    But if I change the "> 50" to "= 50", nothing happens.

    Is that normal?

  • Since the object is moving via timedelta, it's skipping over 50. So if it's moving 100 pixels per second, then it moves 100*timedelta pixels, which results in distance travelled numbers like 50.095lotsmorenumbers. Using distance travelled = 50 would only work if you knew at some point it would equal that, like moving 10 pixels per frame, but then the speed wouldn't be consistent on all computers.

    What you want to do is use the trigger once while true condition after the distance travelled is greater than 50 condition.

  • Object[Bullet].Travelled > 50

    >Set angle to Object.Angle - 40

    Result: keeps spinning.

    Add the 'trigger once' condition below the comparison. The bullet will still have travelled more than 50 pixels every tick after it first reaches 50 pixels, so it keeps running the event every tick.

    As Arima said, you have to be careful making direct comparisons to numbers like that. If the distance travelled was 49 one tick then 51 the next, your event never runs. Even if it has travelled 50.000001 pixels one tick, the event would not run.

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