Hello, I had a question about why my rotation is being weird when I change it to be the direction of the velocity after hitting a wall. The code for that is here:
if movement and "Wall" in movement.get_collider().get_parent().name:
velocity = velocity.bounce(movement.get_normal())
rotation = deg_to_rad(velocity.angle())
And therefore due to this problem when I try to change my direction for the random movement it seems the rotation is unchanged and it causes the agent to keep on coming back in the general direction of the wall as the rotation is not working and so it cannot get a new direction away from the wall and continue into it.
My code for randomly changing the direction, which every 1-3 seconds via another function:
I think it is something due to the fact that the rotation is never really changed when it hit the wall and so after bounding off it comes back like it was doing before.
Even when I try this it doesn’t work as well. Surely when I change the rotation when it hits the wall it should remain that rotation when it next checks random dir it should head in the same general direction and shouldn’t pull a 180 after running the function?