Topic was automatically imported from the old Question2Answer platform.
Asked By
Joubarbe
Old Version
Published before Godot 3 was released.
Hi,
I’m new to Godot and game programming in general.
I know there are move() and move_to() functions for kinematic objects, but what I’d like to know is if it exists a function that take into account rotation, speed, acceleration?
For instance, if I have a ship (2D top-down view) pointing at (0,0), and if I want it to go to (0,180), where the mouse cursor clicked, what is the common way to make it rotate first, then manage to go to its destination? I mean, ships are big, it would need quite some place on the side to rotate. I thought a physics engine could do that easily, so I ask here if that’s the case with Godot.
For limited rotation space:
Kinematics have a test_move function to prevent moving but not a test_rotation or even a collision-aware rotation method, you may need an extra Shape to apply manual overlap checks to prevent undesired movements.
Or just fake it: use areas and/or raycasts to check potential collisions before they happen.
Hmm, thanks for the answer… It’s weird though, I cannot find any example answering to my scenario; even if it’s in another language, it would be appreciated! There’s a lot of maths involved in these kind of move.
Joubarbe | 2016-11-25 20:30
Something simple (and visual) for detections, like a car’s parking sensor:
Just add the overlap/collision checks before rotation attempts.
For more advanced AI, you may want to look for steering behavior techniques, sounds complex at first but once you get your framework in shape your objects will move in a smart way.
In particular, arrival+collision avoidance (areas and raycasts can help to simplify the logic too).