So, basic projectile: RigidBody2d, has a sprite and collision shape. Also has an area2d (for collisions with ground) with it's own shape (both made unique). There is also a collision boolean, to detect collision and stop it.
The spear gets instantiated, is given an impulse of Vector2. The rotation of the spear is controlled by atan2(y,x), to give it a smooth rotation .
However, when the spear collides with the ground, it is given a full stop. All velocities set to zero. Collision boollean is set to false, so the spear is suppesed to stop. Yet, I think there happens one last tick of forces update, screwing up atan2. THEN all process stops, spear gets frozen at this wierd angle
I tried to sus out the values of velocities, but it didn't bear any fruit.
func _integrate_forces(state):
if(collided):
var velo = state.linear_velocity
if velo.y >2 or velo.x > 16: //been toying with this values. Some do work in only specific instances
var angle = atan2(velo.y, velo.x)
self.rotation = angle
print("Y ")
print(velo.y)
print("X ")
print(velo.x)
else:
pass
func _on_body_entered(body):
print("AAAAAAAAAAA") //for debugging
print(linear_velocity.x) //this, and the latter print show that a tik of update doo happen
collided=false
linear_velocity= Vector2.ZERO
print(linear_velocity.x) // this, and the former print show that a tik of update doo happen
angular_velocity=0
gravity_scale =0
pass