Now the visibility/lod/wakeup check has a timer for mobs.

This commit is contained in:
Relintai 2020-05-23 18:49:06 +02:00
parent b4867ec012
commit 6b50033f29
3 changed files with 22 additions and 5 deletions

View File

@ -161,7 +161,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.04, -0.09 )
script = ExtResource( 2 )
[node name="RightHandAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="2"]
transform = Transform( -0.0400955, -0.0242102, -0.998884, -0.127471, -0.991364, 0.0291306, -0.991041, 0.128501, 0.0366712, -0.226341, 0.768569, -0.00640216 )
transform = Transform( -0.0400954, -0.0242101, -0.998884, -0.127471, -0.991364, 0.0291305, -0.991041, 0.128501, 0.0366712, -0.226341, 0.768569, -0.00640216 )
bone_name = "right_hand"
[node name="RightHandAP" type="Spatial" parent="armature/Armature/Skeleton/RightHandAttachment"]
@ -177,7 +177,7 @@ transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0
script = ExtResource( 2 )
[node name="NeckAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="4"]
transform = Transform( 0.99998, -0.00629028, -0.000312272, 0.00629784, 0.997246, 0.0731527, -0.000148758, -0.0731576, 0.99732, 0.00103962, 1.31823, 5.39595e-05 )
transform = Transform( 0.99998, -0.00629028, -0.000312272, 0.00629784, 0.997246, 0.0731527, -0.000148758, -0.0731576, 0.99732, 0.00103962, 1.31823, 5.39597e-05 )
bone_name = "neck"
[node name="TorsoAP" type="Spatial" parent="armature/Armature/Skeleton/NeckAttachment"]

View File

@ -78,6 +78,7 @@ var moving : bool = false
var casting_anim : bool = false
var sleep : bool = false
var sleep_recheck_timer : float = 0
var dead : bool = false
var death_timer : float = 0
@ -89,6 +90,8 @@ var entity : Entity
var model_rotation_node : Spatial
var character_skeleton : CharacterSkeleton3D
var visibility_update_timer : float = 0
func _ready() -> void:
camera = get_node_or_null("CameraPivot/Camera") as Camera
camera_pivot = get_node_or_null("CameraPivot") as Spatial
@ -126,6 +129,13 @@ func _process(delta : float) -> void:
if entity.ai_state == EntityEnums.AI_STATE_OFF:
return
visibility_update_timer += delta
if visibility_update_timer < 1:
return
visibility_update_timer = 0
var camera : Camera = get_tree().get_root().get_camera() as Camera
if camera == null:
@ -167,10 +177,18 @@ func _physics_process(delta : float) -> void:
if dead:
return
if entity.ai_state == EntityEnums.AI_STATE_OFF:
if entity.c_is_controlled:
process_input(delta)
process_movement_player(delta)
else:
if sleep:
sleep_recheck_timer += delta
if sleep_recheck_timer < 0.5:
return
sleep_recheck_timer = 0
if world != null:
if not world.is_position_walkable(transform.origin):
return

View File

@ -61,7 +61,6 @@ max_frame_chunk_build_steps = 4
library = ExtResource( 2 )
level_generator = SubResource( 1 )
voxel_scale = 3.0
chunk_spawn_range = 5
build_flags = 511
script = ExtResource( 8 )