To anyone from the future who is looking for how to designate a "hitter" and "hittee" and find the collision force after a collision as I was, here is the code that does that.
Firstly, in the physics process or integrate physics (Whichever you use) paste the following code:
previous_velocity = current_velocity
current_velocity = self.linear_velocity
Next, go to the physics object's node and access its signals. Connect the node's onbody_entered signal to itself, and find the newly made function in its script, and set it to this:
func _on_Object_body_entered(body):
var hit_force = 0
var hitter = false
if body is RigidBody2D:
if body.get_index()>self.get_index():
if body.previous_velocity == Vector2.ZERO:
hitter = true
hit_force = self.previous_velocity.length()*body.mass
elif self.previous_velocity == Vector2.ZERO:
hitter = false
hit_force = body.previous_velocity.length()*body.mass
else:
var hit_velocity = (body.previous_velocity - self.previous_velocity.project(body.previous_velocity)).length()
var enemy_hit_priority
var our_hit_priority
var collision_angle = abs(sin(previous_velocity.angle_to(body.previous_velocity)*0.5))
if collision_angle == 0:
enemy_hit_priority = body.previous_velocity.length()
our_hit_priority = self.previous_velocity.length()
else:
enemy_hit_priority = body.previous_velocity.length()*(body.mass*collision_angle)
our_hit_priority = self.previous_velocity.length()*(self.mass*collision_angle)
if enemy_hit_priority > our_hit_priority:
hitter = false
else:
hitter = true
hit_force = hit_velocity*body.mass
on_hit(hit_force,hitter)
body.on_hit(hit_force,not hitter)
Now just make the on_hit(hit_force, is_hitter)
function referenced in the code and you're done!
Is it gross? Sure. Is it uncommented because I'm lazy? Yup. Does it work after DAYS OF SEARCHING? Certainly.