summaryrefslogtreecommitdiff
path: root/godot/scripts/ballistics
diff options
context:
space:
mode:
authorAnson Bridges <bridges.anson@gmail.com>2022-09-19 17:44:22 -0400
committerAnson Bridges <bridges.anson@gmail.com>2022-09-19 17:44:22 -0400
commit1d347e770fddcdd051890cdf070fd2779ab113bf (patch)
tree6501fb000509819b7ba58df15c9a831c8bdc44fb /godot/scripts/ballistics
parent2fd755132f526c48fed2c1867530526971e1cf19 (diff)
problems: player controller perf, boat perf, NAVSERVER PERF
Diffstat (limited to 'godot/scripts/ballistics')
-rw-r--r--godot/scripts/ballistics/Cannonball.gd13
1 files changed, 8 insertions, 5 deletions
diff --git a/godot/scripts/ballistics/Cannonball.gd b/godot/scripts/ballistics/Cannonball.gd
index d1937f4..7cf59e5 100644
--- a/godot/scripts/ballistics/Cannonball.gd
+++ b/godot/scripts/ballistics/Cannonball.gd
@@ -1,17 +1,20 @@
extends "res://scripts/ballistics/NetworkedProjectile.gd"
-export var drag_constant = 0.3
+export var drag_constant: float = 0.3
var damage_exceptions = []
-var oldvel
+var oldvel: Vector3
func _physics_process(_delta):
- oldvel = linear_velocity
- add_force(-1*linear_velocity*drag_constant, Vector3.ZERO)
+ if is_network_master():
+ oldvel = linear_velocity
+ add_force(-1*linear_velocity*drag_constant, Vector3.ZERO)
+ if global_transform.origin.y < -20:
+ rpc("net_remove")
func get_init_info():
return {"linear_velocity" : linear_velocity, "angular_velocity" : angular_velocity, "oldvel" : oldvel, "shooter" : shooter, "shooter_id" : shooter_id}
func _on_collision(body):
- if oldvel.length() > 20 and !damage_exceptions.has(body) and body.has_method("damage"):
+ if is_network_master() and oldvel.length() > 20 and !damage_exceptions.has(body) and body.has_method("damage"):
body.rpc("damage", oldvel.length(), "blunt", [shooter_id, shooter], "using 'cannon'")
damage_exceptions.append(body)