Ai rotation in movment

Hey guys
Right now my ai move but when i want him to go backword he just mving there…
I want him to move like a car so he need to trun around
Is there a easy way to do it or you guys can give me a dirction to how i can make it happen cuz right now im pretty much noob in making ai and coding in genral
Thanks

There are a few ways of rotating something. You could set the Quaternion rotation directly (easier than it sounds) or set the Euler.z to the rotation in degrees that you want.

For Euler it looks like this

go.set(".","euler.z", 180)

For Quaternion it can look like this

go.set_rotation(vmath.quat_rotation_z(radian_angle))

I recommend you read through this set of articles if you have not before http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-1/ (It would be worth one of us making a fresh article like this as it applies directly to Defold with the various useful concepts.)

Once you get a grasp of those concepts you may have a better idea on how to do a car like movement with rotation. We can still help you along the way. We all started as noobs.

3 Likes

Thanks i will check it out and if i stiil have problem i will be sure to ask