added enemy inputs as a resource
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://q7uc1h2jpbd2"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://q7uc1h2jpbd2"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bei4nhkf8lwdo" path="res://player_controller/PlayerController.tscn" id="1_62kkh"]
|
||||
[ext_resource type="Material" uid="uid://31aulub2nqov" path="res://assets/greybox/m_greybox.tres" id="2_3uydm"]
|
||||
[ext_resource type="PackedScene" uid="uid://dxt0e2ugmttqq" path="res://scenes/enemies/first_enemy.tscn" id="3_3uydm"]
|
||||
[ext_resource type="Script" uid="uid://b2vdwkiqauhk3" path="res://scenes/enemies/EnemyInitInputs.cs" id="4_nd7vd"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_0xm2m"]
|
||||
sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
|
||||
@@ -26,6 +27,21 @@ ssil_radius = 8.4
|
||||
sdfgi_use_occlusion = true
|
||||
glow_enabled = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8fd2t"]
|
||||
script = ExtResource("4_nd7vd")
|
||||
Speed = 3.2
|
||||
metadata/_custom_type_script = "uid://b2vdwkiqauhk3"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_7m3bq"]
|
||||
script = ExtResource("4_nd7vd")
|
||||
Speed = 2.8
|
||||
metadata/_custom_type_script = "uid://b2vdwkiqauhk3"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_sysok"]
|
||||
script = ExtResource("4_nd7vd")
|
||||
Speed = 6.4
|
||||
metadata/_custom_type_script = "uid://b2vdwkiqauhk3"
|
||||
|
||||
[node name="Main" type="Node3D"]
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("1_62kkh")]
|
||||
@@ -95,11 +111,14 @@ material = ExtResource("2_3uydm")
|
||||
[node name="Enemy" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("3_3uydm")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -16.83681)
|
||||
Target = NodePath("../Player")
|
||||
Inputs = SubResource("Resource_8fd2t")
|
||||
|
||||
[node name="Enemy2" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("3_3uydm")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, -16.83681)
|
||||
Target = NodePath("../Player")
|
||||
Inputs = SubResource("Resource_7m3bq")
|
||||
|
||||
[node name="Enemy3" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("3_3uydm")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.5, 0, -16.83681)
|
||||
Target = NodePath("../Player")
|
||||
Inputs = SubResource("Resource_sysok")
|
||||
|
||||
18
scenes/enemies/EnemyInitInputs.cs
Normal file
18
scenes/enemies/EnemyInitInputs.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class EnemyInitInputs : Resource
|
||||
{
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
public float Speed = 5.0f;
|
||||
|
||||
public EnemyInitInputs()
|
||||
{
|
||||
Speed = 5.0f;
|
||||
}
|
||||
public EnemyInitInputs(float speed)
|
||||
{
|
||||
Speed = speed;
|
||||
}
|
||||
}
|
||||
1
scenes/enemies/EnemyInitInputs.cs.uid
Normal file
1
scenes/enemies/EnemyInitInputs.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b2vdwkiqauhk3
|
||||
@@ -7,8 +7,8 @@ public partial class FirstEnemy : CharacterBody3D
|
||||
[Export]
|
||||
public Node3D Target { get; set; }
|
||||
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
public float Speed = 5.0f;
|
||||
[Export]
|
||||
public EnemyInitInputs Inputs;
|
||||
|
||||
private RayCast3D _wallInFrontRayCast;
|
||||
|
||||
@@ -26,11 +26,11 @@ public partial class FirstEnemy : CharacterBody3D
|
||||
LookAt(targetPlane);
|
||||
|
||||
var velocity = Velocity;
|
||||
velocity.X = direction.X * Speed;
|
||||
velocity.Z = direction.Z * Speed;
|
||||
velocity.X = direction.X * Inputs.Speed;
|
||||
velocity.Z = direction.Z * Inputs.Speed;
|
||||
|
||||
if (_wallInFrontRayCast.IsColliding())
|
||||
velocity.Y = Speed;
|
||||
velocity.Y = Inputs.Speed;
|
||||
else if (!IsOnFloor())
|
||||
velocity += GetGravity() * (float)delta;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user