Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Pelli |
Hi, I am trying to make an AI to play against the pc. The pc is a cannon and has to catch a ball. So I am moving the cannon to the actual ball position, but I need to rotate the cannon to the opposite direction that is facing the ball, like this:
or like this, when ball hits a wall:
I have created an Area2D that detect when the ball enters the area, so I have the ball saved, and I can get the get_linear_velocity() every frame, but is not working, honestly
I don´t know how to do it and I tried a lot of things and I am always getting something that is not the actual direction of the ball
Cannon.rotation = (ball.get_linear_velocity().angle() + deg2rad(180))
that line of code above works for the first image, but not when the ball is hitting something and changing completly the direction like in the second image.