diff options
| author | Anson Bridges <bridges.anson@gmail.com> | 2022-08-31 17:19:49 -0700 |
|---|---|---|
| committer | Anson Bridges <bridges.anson@gmail.com> | 2022-08-31 17:19:49 -0700 |
| commit | e57103a4f99cdc0693471fe772dc7893ff65e855 (patch) | |
| tree | 790c0767197adf7ffc6e61c4b059cfdff0c62b7b /scripts/ballistics | |
| parent | d3998186c9795f2a85148cd5bcfa1bd5b6226cfb (diff) | |
added local servers
Diffstat (limited to 'scripts/ballistics')
| -rw-r--r-- | scripts/ballistics/Cannonball.gd | 11 | ||||
| -rw-r--r-- | scripts/ballistics/NetworkedProjectile.gd | 22 |
2 files changed, 24 insertions, 9 deletions
diff --git a/scripts/ballistics/Cannonball.gd b/scripts/ballistics/Cannonball.gd index e59ca6c..15f35a3 100644 --- a/scripts/ballistics/Cannonball.gd +++ b/scripts/ballistics/Cannonball.gd @@ -1,11 +1,9 @@ -extends RigidBody +extends "res://scripts/ballistics/NetworkedProjectile.gd" 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) @@ -13,12 +11,7 @@ func _physics_process(_delta): 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") + body.rpc("damage", oldvel.length(), "blunt", shooter, "using 'cannon'") damage_exceptions.append(body) diff --git a/scripts/ballistics/NetworkedProjectile.gd b/scripts/ballistics/NetworkedProjectile.gd new file mode 100644 index 0000000..0626e9f --- /dev/null +++ b/scripts/ballistics/NetworkedProjectile.gd @@ -0,0 +1,22 @@ +extends RigidBody + + +var shooter = "WORLD" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + +func mp_init(init_info): + for variable in init_info.keys(): + set(variable, init_info[variable]) + +remote func update_phys_transform(t, lv, av): + transform = t + linear_velocity = lv + angular_velocity = av + +func _integrate_forces(state): + if is_network_master(): + rpc("update_phys_transform", transform, linear_velocity, angular_velocity) |
