Race car and drifting

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hello

    I'm working on a top down racer and i'm having some problems getting the ai cars moving the way i want them to

    It's setup so they move from node to node, always targeting the next node. This works fine with vector movement but the problem is they don't drift. It's like they're glued to the track

    I've tried to achieve something similar using physics instead but i can't make it work. I suspect this is because of my less than stellar trigonometry skills but here is what i've tried so far

    - compare the angle of the car with the angle between the car and the next node and then rotate accordingly while applying force at the current angle of the car. This sorta works except sometimes they will drive a full extra circle

    - use the advanced directional object. That just opened a new can of worms since i've never used it before and looking through the samples i didn't really find anything i could apply to my situation

    So any help would be very much appreciated

    Either with applying drifting using the vector movement or a physics setup that actually works, as in the ai cars are able to determine if they're within 10 degrees of a given node and if not, rotate towards it and then apply force

    Thanks!:D

    [SIGPIC][/SIGPIC]

    Edited once, last by jn2002dk (July 9, 2017 at 2:29 PM).

  • I figured it out and as suspected it was due to my lack of trigonometry skills

    In case anyone needs something similar i used this check

    (oangle("Car",x("Node"),y("Node")-angle("Car")+360))mod360>180

    to determine if the car should have negative or positive rotation

    [SIGPIC][/SIGPIC]

  • Glad to see you back at work with Fusion ;D

    Seems like you already solved it, but in case you could find it useful,
    I always copy-paste this nice expression in such situations:

    Atan2(Sin(target_angle - current_angle), cos(target_angle - current_angle))

    this will give you the signed angular difference between the "desired" angle (i.e. angle towards target point)
    and the current angle of tested object
    knowing this you can easily use it to rotate towards destination at desired speed

    i.e.

    set ang_diff to = Atan2(Sin(target_angle - current_angle), cos(target_angle - current_angle))

    set current_angle to = current_angle + (ang_diff)/abs(ang_diff) * ang_diff/10.0

    a selection of my Fusion examples can be found Please login to see this link.

  • Hello Schrodinger!

    Thanks for the welcome back:D

    and thanks for that bit of code. That will come in handy for sure!

    Yes, Fusion is king and Fusion 3 looks amazing!

    [SIGPIC][/SIGPIC]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!