oh my god let's try this again
This commit is contained in:
21
scripts/telekinesis_object.gd
Normal file
21
scripts/telekinesis_object.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
extends RigidBody3D
|
||||
|
||||
var grabbable : bool = true
|
||||
@export var damage : float = 6.0
|
||||
@export var min_damaging_velocity : float = 1.0
|
||||
|
||||
func _ready():
|
||||
contact_monitor = true
|
||||
max_contacts_reported = 2
|
||||
set_collision_mask_value(2, true)
|
||||
body_entered.connect(_on_body_entered)
|
||||
|
||||
func _on_body_entered(body):
|
||||
if body.get("shootable") == true:
|
||||
var totalvelocity = abs(angular_velocity.x + angular_velocity.y + angular_velocity.z)
|
||||
if totalvelocity > (3 * min_damaging_velocity):
|
||||
if body.get("rootnode") == true:
|
||||
body.deal_damage(totalvelocity * damage)
|
||||
else:
|
||||
body.owner.deal_damage(totalvelocity * damage)
|
||||
apply_central_impulse(body.position.direction_to(position) * -3.0)
|
||||
Reference in New Issue
Block a user