From d3998186c9795f2a85148cd5bcfa1bd5b6226cfb Mon Sep 17 00:00:00 2001 From: Anson Bridges Date: Wed, 31 Aug 2022 00:26:34 -0700 Subject: Initialize repo --- scripts/ballistics/Cannonball.gd | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 scripts/ballistics/Cannonball.gd (limited to 'scripts/ballistics') diff --git a/scripts/ballistics/Cannonball.gd b/scripts/ballistics/Cannonball.gd new file mode 100644 index 0000000..e59ca6c --- /dev/null +++ b/scripts/ballistics/Cannonball.gd @@ -0,0 +1,24 @@ +extends RigidBody + +export var drag_constant = 0.3 +var damage_exceptions = [] +var oldvel + +var shooter = "WORLD" + +func _physics_process(_delta): + oldvel = linear_velocity + add_force(-1*linear_velocity*drag_constant, Vector3.ZERO) + +func get_init_info(): + return {"linear_velocity" : linear_velocity, "angular_velocity" : angular_velocity, "oldvel" : oldvel, "shooter" : shooter} + +func mp_init(init_info): + for variable in init_info.keys(): + set(variable, init_info[variable]) + + +func _on_collision(body): + if linear_velocity.length() > 20 and !damage_exceptions.has(body) and body.has_method("damage"): + body.damage(oldvel.length(), "blunt") + damage_exceptions.append(body) -- cgit v1.2.3