giants-godot/shaders/water/Water.gd

24 lines
637 B
GDScript3
Raw Normal View History

2021-09-22 18:04:03 +02:00
extends MeshInstance
func _on_Area_body_entered(body):
var body_velocity = Vector3.ZERO
if body is KinematicBody:
body_velocity = body.velocity
elif body is RigidBody:
body_velocity = body.linear_velocity
var force = body_velocity.length()
if body.has_method("enter_water"):
body.enter_water(force)
func _on_Area_body_exited(body):
var body_velocity = Vector3.ZERO
if body is KinematicBody:
body_velocity = body.velocity
elif body is RigidBody:
body_velocity = body.linear_velocity
var _height_speed = -body_velocity.y
var force = body_velocity.length()
if body.has_method("exit_water"):
body.exit_water(force)