added deposit robot
This commit is contained in:
File diff suppressed because one or more lines are too long
BIN
assets/Models/DepositBot.blend
Normal file
BIN
assets/Models/DepositBot.blend
Normal file
Binary file not shown.
53
assets/Models/DepositBot.blend.import
Normal file
53
assets/Models/DepositBot.blend.import
Normal file
@@ -0,0 +1,53 @@
|
||||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://kft3pjbe40vx"
|
||||
path="res://.godot/imported/DepositBot.blend-7f98a9daab07979bad670eaa5d77d82d.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Models/DepositBot.blend"
|
||||
dest_files=["res://.godot/imported/DepositBot.blend-7f98a9daab07979bad670eaa5d77d82d.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
blender/nodes/visible=0
|
||||
blender/nodes/active_collection_only=false
|
||||
blender/nodes/punctual_lights=true
|
||||
blender/nodes/cameras=true
|
||||
blender/nodes/custom_properties=true
|
||||
blender/nodes/modifiers=1
|
||||
blender/meshes/colors=false
|
||||
blender/meshes/uvs=true
|
||||
blender/meshes/normals=true
|
||||
blender/meshes/export_geometry_nodes_instances=false
|
||||
blender/meshes/tangents=true
|
||||
blender/meshes/skins=2
|
||||
blender/meshes/export_bones_deforming_mesh_only=false
|
||||
blender/materials/unpack_enabled=true
|
||||
blender/materials/export_materials=1
|
||||
blender/animation/limit_playback=true
|
||||
blender/animation/always_sample=true
|
||||
blender/animation/group_tracks=true
|
||||
BIN
assets/Models/DepositBot.blend1
Normal file
BIN
assets/Models/DepositBot.blend1
Normal file
Binary file not shown.
@@ -867,38 +867,32 @@ taunts = Array[String](["did i do that?", "you've been on my shitlist", "you lik
|
||||
script = ExtResource("6_87l3v")
|
||||
initial_state = NodePath("Idle")
|
||||
|
||||
[node name="Idle" type="Node" parent="StateMachine" node_paths=PackedStringArray("enemy")]
|
||||
[node name="Idle" type="Node" parent="StateMachine"]
|
||||
script = ExtResource("7_cwyr0")
|
||||
enemy = NodePath("../..")
|
||||
move_speed = 1.5
|
||||
turret_speed = 0.5
|
||||
poi_investigate = true
|
||||
poi_change_to_search = true
|
||||
|
||||
[node name="Stunned" type="Node" parent="StateMachine" node_paths=PackedStringArray("enemy")]
|
||||
[node name="Stunned" type="Node" parent="StateMachine"]
|
||||
script = ExtResource("8_wpql0")
|
||||
enemy = NodePath("../..")
|
||||
|
||||
[node name="Die" type="Node" parent="StateMachine" node_paths=PackedStringArray("enemy")]
|
||||
[node name="Die" type="Node" parent="StateMachine"]
|
||||
script = ExtResource("9_6mvds")
|
||||
enemy = NodePath("../..")
|
||||
metadata/_custom_type_script = "uid://dhxolagi0b5s1"
|
||||
|
||||
[node name="Attack" type="Node" parent="StateMachine" node_paths=PackedStringArray("alert_sound", "enemy")]
|
||||
[node name="Attack" type="Node" parent="StateMachine" node_paths=PackedStringArray("alert_sound")]
|
||||
script = ExtResource("10_gicen")
|
||||
alert_sound = NodePath("../../AUIDO/Alarm")
|
||||
enemy = NodePath("../..")
|
||||
body_turn_speed = 1.0
|
||||
|
||||
[node name="Reload" type="Node" parent="StateMachine" node_paths=PackedStringArray("reload_sound", "servo_sound", "enemy")]
|
||||
[node name="Reload" type="Node" parent="StateMachine" node_paths=PackedStringArray("reload_sound", "servo_sound")]
|
||||
script = ExtResource("11_ekglj")
|
||||
reload_sound = NodePath("../../AUIDO/Reload")
|
||||
servo_sound = NodePath("../../AUIDO/ServoSingle")
|
||||
enemy = NodePath("../..")
|
||||
|
||||
[node name="Search" type="Node" parent="StateMachine" node_paths=PackedStringArray("enemy")]
|
||||
[node name="Search" type="Node" parent="StateMachine"]
|
||||
script = ExtResource("12_aasxo")
|
||||
enemy = NodePath("../..")
|
||||
poi_investigate = true
|
||||
poi_update_waypoint_immediately = true
|
||||
|
||||
|
||||
40
deposit_bot.tscn
Normal file
40
deposit_bot.tscn
Normal file
@@ -0,0 +1,40 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://c10cvl6w5rn61"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://kft3pjbe40vx" path="res://assets/Models/DepositBot.blend" id="1_0tmrv"]
|
||||
[ext_resource type="Script" uid="uid://cga1rh0t3ey77" path="res://scripts/deposit_bot.gd" id="1_2eu0f"]
|
||||
[ext_resource type="Script" uid="uid://csju024nerln6" path="res://scripts/StateMachine.gd" id="1_naihy"]
|
||||
[ext_resource type="Script" uid="uid://bgoq8rrojxt32" path="res://scripts/NPCIdle.gd" id="2_icugd"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_yndd5"]
|
||||
radius = 0.36
|
||||
|
||||
[node name="DepositBot" type="CharacterBody3D" node_paths=PackedStringArray("state_machine", "nav_agent")]
|
||||
collision_layer = 65
|
||||
collision_mask = 577
|
||||
script = ExtResource("1_2eu0f")
|
||||
state_machine = NodePath("StateMachine")
|
||||
nav_agent = NodePath("NavigationAgent3D")
|
||||
|
||||
[node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("initial_state")]
|
||||
script = ExtResource("1_naihy")
|
||||
initial_state = NodePath("Idle")
|
||||
|
||||
[node name="Idle" type="Node" parent="StateMachine" node_paths=PackedStringArray("character")]
|
||||
script = ExtResource("2_icugd")
|
||||
wander_distance_max = 40.0
|
||||
character = NodePath("../..")
|
||||
move_speed = 1.0
|
||||
|
||||
[node name="DepositBot" parent="." instance=ExtResource("1_0tmrv")]
|
||||
transform = Transform3D(-1.25, 0, -1.09278e-07, 0, 1.25, 0, 1.09278e-07, 0, -1.25, 0, 0, 0)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
shape = SubResource("CapsuleShape3D_yndd5")
|
||||
|
||||
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
|
||||
path_height_offset = 0.5
|
||||
avoidance_enabled = true
|
||||
radius = 1.5
|
||||
|
||||
[connection signal="velocity_computed" from="NavigationAgent3D" to="." method="_on_navigation_agent_3d_velocity_computed"]
|
||||
6
hud.tscn
6
hud.tscn
@@ -1,13 +1,10 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://br882tlh3cfwu"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://br882tlh3cfwu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dfv2m81iew3ia" path="res://scripts/hud.gd" id="1_7hukm"]
|
||||
[ext_resource type="Theme" uid="uid://clek42ofxr45f" path="res://DefaultTheme.tres" id="1_22trs"]
|
||||
[ext_resource type="Script" uid="uid://x40xk7ltmrgr" path="res://scripts/minimap_v1.gd" id="3_640wx"]
|
||||
[ext_resource type="Script" uid="uid://cfou02ggxj80n" path="res://scripts/dynamic_crosshair.gd" id="5_1xsix"]
|
||||
|
||||
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_640wx"]
|
||||
blend_mode = 1
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_2hn4h"]
|
||||
bg_color = Color(1, 1, 1, 0.129412)
|
||||
corner_radius_top_left = 5
|
||||
@@ -55,7 +52,6 @@ grow_vertical = 2
|
||||
script = ExtResource("5_1xsix")
|
||||
|
||||
[node name="Minimap" type="Control" parent="StaticItems" node_paths=PackedStringArray("hud")]
|
||||
material = SubResource("CanvasItemMaterial_640wx")
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
|
||||
@@ -12,7 +12,7 @@ config_version=5
|
||||
|
||||
config/name="First Person Test"
|
||||
config/tags=PackedStringArray("fps")
|
||||
run/main_scene="uid://b55ukxds1s7ih"
|
||||
run/main_scene="uid://f7e0v1r6ra6c"
|
||||
config/features=PackedStringArray("4.4", "Forward Plus")
|
||||
config/icon="uid://6svuq1l83al5"
|
||||
|
||||
|
||||
91
scripts/CharacterStates.gd
Normal file
91
scripts/CharacterStates.gd
Normal file
@@ -0,0 +1,91 @@
|
||||
extends State
|
||||
class_name CharacterState
|
||||
|
||||
@export var character : CharacterBody3D
|
||||
@export var move_speed : float = 3
|
||||
@export var body_turn_speed : float = 3
|
||||
@export var turret_speed : float = 6.0
|
||||
@export var can_see : bool = true # indicates whether the character is able to see things in the state
|
||||
@export var poi_investigate : bool = false
|
||||
@export var poi_change_to_search : bool = false
|
||||
@export var poi_update_waypoint_immediately : bool = false
|
||||
|
||||
var move_target
|
||||
var look_target
|
||||
|
||||
func character_has_target():
|
||||
if character.player_last_seen != null:
|
||||
return true
|
||||
if character.point_of_interest != null:
|
||||
return true
|
||||
return false
|
||||
|
||||
func update_move_target():
|
||||
if character.player_last_seen != null:
|
||||
return character.player_last_seen
|
||||
elif character.point_of_interest != null:
|
||||
return character.point_of_interest["point"]
|
||||
else:
|
||||
return character.global_position
|
||||
|
||||
func search_on_lost_target():
|
||||
if !character.is_player_visible():
|
||||
Transitioned.emit(self,"attack")
|
||||
|
||||
func move_target_adj(position):
|
||||
return Vector3(position.x,character.global_position.y,position.z)
|
||||
|
||||
func rotate_to_face2D(object,target,target_offset_angle,delta,turn_speed):
|
||||
#to allow both nodes and positions to be passed to this function, test the target and use Vector3 coords
|
||||
var target_transformed
|
||||
if target == null:
|
||||
target_transformed = object.global_position
|
||||
elif target is Vector3:
|
||||
target_transformed = target
|
||||
elif target is Node3D:
|
||||
target_transformed = target.global_position
|
||||
|
||||
var pos2d = Vector2(object.global_position.x,object.global_position.z)
|
||||
var target_pos2d = Vector2(target_transformed.x,target_transformed.z)
|
||||
var direction = (pos2d - target_pos2d)
|
||||
return lerp_angle(object.global_rotation.y,atan2(direction.x,direction.y) + deg_to_rad(target_offset_angle),delta * turn_speed)
|
||||
|
||||
func rotate_to_face3D(object : Node3D,target,target_offset_angle : Vector3,delta : float,turn_speed : float):
|
||||
if target == null:
|
||||
return
|
||||
|
||||
var target_positon
|
||||
|
||||
if target is Vector3:
|
||||
target_positon = target
|
||||
else:
|
||||
target_positon = target.global_position
|
||||
|
||||
var desired_rotation = object.global_transform.looking_at(target_positon,Vector3.UP).basis.get_euler()
|
||||
var current_rotation = object.global_rotation
|
||||
|
||||
#Interpolate each axis
|
||||
current_rotation.x = lerp_angle(current_rotation.x,desired_rotation.x + target_offset_angle.x,delta * turn_speed)
|
||||
current_rotation.y = lerp_angle(current_rotation.y,desired_rotation.y + target_offset_angle.y,delta * turn_speed)
|
||||
current_rotation.z = lerp_angle(current_rotation.z,desired_rotation.z + target_offset_angle.z,delta * turn_speed)
|
||||
|
||||
#clamp pitch
|
||||
var max_downward_pitch = deg_to_rad(85)
|
||||
var min_upward_pitch = deg_to_rad(-45)
|
||||
current_rotation.x = clamp(current_rotation.x,min_upward_pitch, max_downward_pitch)
|
||||
|
||||
object.global_rotation = current_rotation
|
||||
|
||||
func move_to_nav_point(delta):
|
||||
var destination = character.nav_agent.get_next_path_position()
|
||||
var local_destination = destination - character.global_position
|
||||
var new_velocity = local_destination.normalized() * move_speed
|
||||
|
||||
character.nav_agent.set_velocity(new_velocity)
|
||||
character.global_rotation.y = rotate_to_face2D(character,destination,0,delta,body_turn_speed)
|
||||
|
||||
func velocity_computed(safe_velocity):
|
||||
character.velocity = character.velocity.move_toward(safe_velocity,.25)
|
||||
|
||||
func update_minimap(priority,duration,color):
|
||||
SignalBus.emit_signal("ui_minimap_point",character,character.global_position,1,duration,color)
|
||||
1
scripts/CharacterStates.gd.uid
Normal file
1
scripts/CharacterStates.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dpf360834kfoo
|
||||
22
scripts/NPCIdle.gd
Normal file
22
scripts/NPCIdle.gd
Normal file
@@ -0,0 +1,22 @@
|
||||
extends CharacterState
|
||||
class_name NPCIdle
|
||||
|
||||
@export var wander_distance_max : float = 15.0
|
||||
@export var scan_time : float = 3
|
||||
|
||||
func Enter():
|
||||
get_new_wander_point()
|
||||
|
||||
func Update(delta):
|
||||
#if navigation is finished get new point, otherwise continue on path
|
||||
if character.nav_agent.is_navigation_finished():
|
||||
get_new_wander_point()
|
||||
else:
|
||||
move_to_nav_point(delta)
|
||||
|
||||
func get_new_wander_point():
|
||||
var x = randf_range(-wander_distance_max,wander_distance_max)
|
||||
var z = randf_range(-wander_distance_max,wander_distance_max)
|
||||
move_target = character.global_position + Vector3(x,0,z)
|
||||
character.nav_agent.set_target_position(move_target)
|
||||
print("MOVE TARGET : ",move_target)
|
||||
1
scripts/NPCIdle.gd.uid
Normal file
1
scripts/NPCIdle.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bgoq8rrojxt32
|
||||
@@ -1,4 +1,5 @@
|
||||
extends Node
|
||||
class_name StateMachine
|
||||
|
||||
@export var initial_state : State
|
||||
|
||||
|
||||
12
scripts/deposit_bot.gd
Normal file
12
scripts/deposit_bot.gd
Normal file
@@ -0,0 +1,12 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
@export var state_machine : StateMachine
|
||||
@export var nav_agent : NavigationAgent3D
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
move_and_slide()
|
||||
|
||||
|
||||
func _on_navigation_agent_3d_velocity_computed(safe_velocity: Vector3) -> void:
|
||||
state_machine.current_state.velocity_computed(safe_velocity)
|
||||
1
scripts/deposit_bot.gd.uid
Normal file
1
scripts/deposit_bot.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cga1rh0t3ey77
|
||||
Reference in New Issue
Block a user