How do I change angle smoothly?

0 favourites
  • 6 posts
From the Asset Store
3D Car Pack 1
$2.99 USD
3D models + Rendered Low-Poly Cars in isometric, top-down, and side angles.
  • im using bullet behavior

    and every 1 second use expression

    set angle

    int(random(0, 360))

    what i can make to change this angle smoothly because now its skipping between angles

  • Set a TargetAngle variable instead of the actual angle.

    Then have the bullet rotate towards TargetAngle.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Set a TargetAngle variable instead of the actual angle.

    Then have the bullet rotate towards TargetAngle.

    I thought that will be easy, can you show this in capx?

  • Have several instance variables in your bullet object :

    • TargetAngle - Numeric
    • Shifting - Boolean (False by default)

    // Sets the random value and tells the bullet it needs to shift in that direction

    Event condition Every 1 sec

    • action Set TargetAngle value to random(0,360)
    • action set boolean Shifting to True

    // The bullet is shifting in the target direction

    Event condition Bullet Boolean Shifting is true

    • Action Set Bullet.Bullet.AngleOfMotion to anglelerp(Bullet.Bullet.AngleOfMotion, Bullet.TargetAngle, dt * 4)

    // We check a range where the angle of motion could be to stop the shifting

    Sub event

    condition System compare two values - Bullet.Bullet.AngleOfMotion + 2 < Bullet.TargetAngle

    AND

    condition System Compare two values - Bullet.Bullet.AngleOfMotion - 2 > Bullet.TargetAngle

    • Action - Set Bullet.Angle of motion to Bullet.TargetAngle
    • Action - Set Shifting to False
  • Have several instance variables in your bullet object :

    - TargetAngle - Numeric

    - Shifting - Boolean (False by default)

    // Sets the random value and tells the bullet it needs to shift in that direction

    Event condition Every 1 sec

    - action Set TargetAngle value to random(0,360)

    - action set boolean Shifting to True

    // The bullet is shifting in the target direction

    Event condition Bullet Boolean Shifting is true

    - Action Set Bullet.Bullet.AngleOfMotion to anglelerp(Bullet.Bullet.AngleOfMotion, Bullet.TargetAngle, dt * 4)

    // We check a range where the angle of motion could be to stop the shifting

    Sub event

    condition System compare two values - Bullet.Bullet.AngleOfMotion + 2 < Bullet.TargetAngle

    AND

    condition System Compare two values - Bullet.Bullet.AngleOfMotion - 2 > Bullet.TargetAngle

    - Action - Set Bullet.Angle of motion to Bullet.TargetAngle

    - Action - Set Shifting to False

    you mean something like that?

    https://www.dropbox.com/s/v7al1u6ujtoh9 ... 7.png?dl=0

  • Both conditions "System - Compare two values" in the same sub event (hence the AND).

    And both actions in that sub-event.

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