I have a little issue trying to use the Physics2D and RigidBody2D collision system.
I made a 500x500 window with StaticBody2D and RectangleShapes as border. then I put a Rigidbody2D ball with a Sprite2D and CircleShape2D and removed gravity. now I made the ball constantly accelerate. here is the problem, the ball accelerate has it is intended to, but as it gains more and more speed it lasts by fleeing out of the screen.
So how can I prevent the ball of doing this. I've looked the internet to find the correct solution, but I cannot figure out what is the correct answer for godot.
here is the code for the ball:
var speed = 2000
var vect = getlinear_velocity()
return (abs(vect.x) + abs(vect.y))
var vect = getlinearvelocity()
var spd = get_speed()
if spd < speed - 1:
vect *= 1.025
elif spd > speed + 1:
vect *= 0.975
and there is a screenshot of the project:
Thank you for your time.