diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2022-10-09 04:45:45 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2022-10-09 04:46:01 -0400 |
commit | f7ec57998a1c3d0cf91c1fb017fd5a91bb1e0b96 (patch) | |
tree | ce0fbf5ed79731da5b216327a2e5cdc59df39fc6 /Float.gd | |
parent | 4c9b0fdd23eda730abdc35f935bc011a3aea0765 (diff) | |
download | godot_wildjam_49-duso-water-touchups.tar.gz godot_wildjam_49-duso-water-touchups.zip |
Rework Buoyancy physicsduso-water-touchups
Simplify creating a buoyant object to just extending a class and setting the water plane.
Implement a new buoyancy estimation that should be a bit more accurate.
Diffstat (limited to 'Float.gd')
-rw-r--r-- | Float.gd | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/Float.gd b/Float.gd deleted file mode 100644 index 77ffa95..0000000 --- a/Float.gd +++ /dev/null @@ -1,15 +0,0 @@ -extends Spatial - -onready var inv_gravity = -ProjectSettings.get_setting("physics/3d/default_gravity_vector") * ProjectSettings.get_setting("physics/3d/default_gravity") - -func _physics_process(_delta): - var parent = get_parent() - var water = get_node("/root/Main/Water") - var height = self.global_transform.origin.y - var wave_height = water.height(self.global_transform.origin) - if height < wave_height: - var pos = self.global_transform.origin-parent.global_transform.origin - #buoyancy force is weight of the displaced water - #we can estimate it by how deep we are in the water - var buoyancy = inv_gravity * clamp(wave_height-height,0.0,1.0) - parent.add_force(buoyancy, pos) |