How to attach actor's speed to it's direction

kapserkapser Member Posts: 458
edited November -1 in Working with GS (Mac)
I'm not sure how simple question this question is: I'm trying to have an object change direction when I rotate it, but since velocity isn't attached to a direction I'm not sure the best way to achieve thir.

I don't want my actor to drift like in the Space Rock or car template.

Comments

  • kapserkapser Member Posts: 458
    Bump. I should stop posting topics in the middle of the night XD
  • kapserkapser Member Posts: 458
    Not sure my question was clear. I'm using accelerate relative to actor.

    But then when I rotate my actor, the speed won't follow actor's direction but only it's acceleration will so the actor will drift instead of just turning. I would like the actor's velocity to follow actor's direction when I'm rotating it.

    I can achieve this by having a very high acceleration with a max speed, but then I won't be able to normally accelerate. There must be a better way to do this.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I have an idea but it depends on what you are using to control the actor. It is a right and left button or a accelerate towards touch this may work. If it is joystick it won't.

    when button is pressed change linear.velocity.X to 0 and linear.velocity.Y to 0 then have your accelerate behavior after that. That way it stops and then goes towards the new direction. May want to use move with this or just change velocity.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    have you tried just adding a bunch of drag in the actor thats accelerating? drag is under its physics attributes. An acceleration will keep you accelerating even when you left off and thats what gives you that drift type movement, adding drag will stop that
  • kapserkapser Member Posts: 458
    Thanks guys. I couldn't make both of these solutions work, but it should give me some inspiration to find a way to make it work.

    Since I want an acceleration, reseting velocity to 0 will just stop the actor every time I turn. Adding a lot of drag doesn't seem to change anything.

    I guess using velocity with a direction might require some mathematical equation or something.
  • micksolomicksolo Member Posts: 264
    pretty sure there is a car demo that has handling like this - just search around for car demo's until you find the one I mean (sorry can't remember off the top of my head)
  • CreativeRightCreativeRight Member, PRO Posts: 11
    edited January 2012
    Finally! Thnaks JohnPapiomitis! Ive had this drifting problem with my game Narco Sub for ever, I just adjusted the drag and bam! no more drift, Check out the youtube video of what it used to look like, now it drives like a charm. Thanks!


    Cheers!
Sign In or Register to comment.