24 lines
637 B
GDScript3
24 lines
637 B
GDScript3
|
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)
|