GML "Mount" collision circles to objects?

Hi, I am creating traffic AI, and would like to make it so I can have "sensors" on the front corners of the car for it to be able to turn around other objects. Right now, when the car turns, the collision circle does not turn with the car...
 
Last edited:
L

Lt. Farfetch'd

Guest
What’s your current implementation?
Does turning involve just modifying the image-angle? Are you creating a new instance for the turning car?

It might be helpful if you could provide some code so that there are some clear constraints for a viable answer to work within.

If you’ve got your cars moving then you’re already computing the circle centres in some sort of dynamic way. My guess is that you’ll need a formula which factors in the rotation of the vehicle - which sounds like some fun trigonometric or vector math.
 
What’s your current implementation?
Does turning involve just modifying the image-angle? Are you creating a new instance for the turning car?

It might be helpful if you could provide some code so that there are some clear constraints for a viable answer to work within.

If you’ve got your cars moving then you’re already computing the circle centres in some sort of dynamic way. My guess is that you’ll need a formula which factors in the rotation of the vehicle - which sounds like some fun trigonometric or vector math.
Easy there, I'm not liking those big words (I'm barely passing 10th grade math) The turning is based off of changing the image angle. Here is the turning code a YouTuber gave out.
Code:
if(speed > 0){
        pointDir = point_direction( x , y , myGuide.x , myGuide.y );
        image_angle += sin(degtorad(pointDir - image_angle)) * rSpeed;
    }
(The speed > 0 if statement is so the the car can't turn when it's still) You know how traffic AI works in real games? If not, basically the AI follows a guide point, which follows the path. Right now, instead of the car itself seeing, for example, the player, the collision between the player and the guide is stopping the guide point, and the car is using distance_to_object, so when the car gets close to the guide, it stops. It's weird because if the player is in between the guide and the car, the car wont notice the player and run them over.

I'm not going to be able to sleep until I get this figured out...........
 
Top