Deceleration

keekee312keekee312 Member Posts: 91
edited November -1 in Working with GS (Mac)
Hi, I tried to make actors slow down when a button is pressed but it does nothing and I don't know why. I put a boolean when the button is clicked => For 5sec : DECELERATE is true

and in each actor : when DECELERATE is true... (and now i tried to change velocity, drag, apply a max speed etc but nothing works)

Thank you

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    maybe try using an acceleration behavior. For the angle use VectorToAngle(self.linear.X,self.linear.Y)+180 so that it accelerates in the opposite direction of motion. Use it in a timer.

    Never tried this but it's worth a shot.
  • synthesissynthesis Member Posts: 1,693
    Trying using an interpolation behavior that increases DRAG. Drag is similar to "wind resistance" and the higher it is...the harder it is for the actor to move/accelerate. Think of it as brakes.

    So...when decelerate = false >>> accelerate (is on) and drag (is small)
    otherwise >>> accelerate (is off) and DRAG interpolates to self.dragMax over 5 sec.

    Make sense?
  • keekee312keekee312 Member Posts: 91
    @synthesis : Great !! It works BUT it slows down actors which are already falling down but actors which are just spawn are stuck to the top of the screen, how can I fix that please ?

    @scitunes : Thanks I'll maybe try this

    Thanks for your quick answers
  • keekee312keekee312 Member Posts: 91
    Finally it works.

    When DECELERATE = false
    => accelerate : 300

    otherwise : accelerate : 50
    After 5 sec = decelerate = false
Sign In or Register to comment.