Now entities will be snapped to the terrarin after they spawn.

This commit is contained in:
Relintai 2020-06-13 15:30:49 +02:00
parent bb955630fc
commit 315df2a10a

View File

@ -91,6 +91,7 @@ var model_rotation_node : Spatial
var character_skeleton : CharacterSkeleton3D var character_skeleton : CharacterSkeleton3D
var visibility_update_timer : float = 0 var visibility_update_timer : float = 0
var placed : bool = false
func _ready() -> void: func _ready() -> void:
camera = get_node_or_null("CameraPivot/Camera") as Camera camera = get_node_or_null("CameraPivot/Camera") as Camera
@ -177,6 +178,22 @@ func _physics_process(delta : float) -> void:
if dead: if dead:
return return
if not placed:
if world != null:
if not world.is_position_walkable(transform.origin):
return
var space : PhysicsDirectSpaceState = get_world().direct_space_state
var res : Dictionary = space.intersect_ray(transform.origin, transform.origin + Vector3(0, -100, 0), [ self ])
if not res.empty():
var pos : Vector3 = res["position"]
transform.origin = pos + Vector3(0, 0.2, 0)
placed = true
return
if entity.c_is_controlled: if entity.c_is_controlled:
process_input(delta) process_input(delta)
process_movement_player(delta) process_movement_player(delta)