Bullet angle of motion resets when you set speed to 0?

0 favourites
  • 5 posts
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • Hi! I used the bullet behavior to animate a sprite and I wanted to pause it for a short time and let it flash when it reaches a certain point. I used "on collision with object" and then set bullet speed to 0, let it flash, wait 2 sec and then set speed to 100 again. But it will reset the angle of motion to 0 to move it to the right (it was set on Startup to 90 to move from top to bottom). Is this a bug?

    When I use Bullet: Set enabled it works fine, it stops and starts with the same angle.

  • Hi! I used the bullet behavior to animate a sprite and I wanted to pause it for a short time and let it flash when it reaches a certain point. I used "on collision with object" and then set bullet speed to 0, let it flash, wait 2 sec and then set speed to 100 again. But it will reset the angle of motion to 0 to move it to the right (it was set on Startup to 90 to move from top to bottom). Is this a bug?

    When I use Bullet: Set enabled it works fine, it stops and starts with the same angle.

    It is not a bug in the sense "it is not a wrong value" (since at a speed of 0, every angle of motion is valid, mathematically it would result in a divide 0 by 0 to calcul it, so instead of having a mathematical error in that particular case it just pick 0 by default for some reason), I suggest if you need to set the speed to 0 someday, first store the angle of motion into an instance variable, so you can re-use it later.

    Edit:when the behavior is disabled, it just means that is skipped, so the values should still be valid, but aren t re calculated nor interpreted

  • I have the same problem when I was adding pause in the game and in my opinion its a bug because I set the speed at 0 and not the angle of motion.

    Disable/enable bullet won't help me in my case so we have to store the angle of motion in a variable for 10.000+ objects

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Internally, Construct never actually stores an "AngleOfMotion" value. Whenever the behavior or user needs the value, it recomputes the value via the arctangent based on the current vx/vy, these being the horizontal and vertical velocity values. This means that when you set speed to 0, vx and vy also get zeroed out and the angle now returns 0.

    If vx and vy were instead inferred from angle and speed (aka: vx = cos(angle) * speed, vy = sin(angle) * speed) then this issue wouldn't occur.

    Steely

    I'd recommend taking a look at using the system time scale (setting it to zero) to create a pause for the game instead of manually managing all the objects.

  • Internally, Construct never actually stores an "AngleOfMotion" value. Whenever the behavior or user needs the value, it recomputes the value via the arctangent based on the current vx/vy, these being the horizontal and vertical velocity values. This means that when you set speed to 0, vx and vy also get zeroed out and the angle now returns 0.

    If vx and vy were instead inferred from angle and speed (aka: vx = cos(angle) * speed, vy = sin(angle) * speed) then this issue wouldn't occur.

    Steely

    I'd recommend taking a look at using the system time scale (setting it to zero) to create a pause for the game instead of manually managing all the objects.

    cacotigon

    Thanks for the explanation, its more clear for me now but I can't use the pause with timescale now, I need only a part of the game to set at pause, but I figured it already out with the power of families.

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