0 Favourites

How do I change angle smoothly?

  • 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.

  • Construct 3

    Buy Construct 3

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

    Buy 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)
Similar Topics Posts Views Last Post
Unread hot topic Locked topic
195 16,196
Ashley's avatar
Ashley Construct Team Founder
Unread hot topic
99 10,136
karshinkoff's avatar
karshinkoff
Unread hot topic
102 6,402
Ashley's avatar
Ashley Construct Team Founder