Buddy system

This commit is contained in:
2023-07-14 10:23:34 -07:00
parent 091b80e384
commit 20519279b1
13 changed files with 533 additions and 25 deletions

320
Models/moogle.gltf Normal file

File diff suppressed because one or more lines are too long

32
Models/moogle.gltf.import Normal file
View File

@@ -0,0 +1,32 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://c13g5orvyhy1p"
path="res://.godot/imported/moogle.gltf-cb3e71457a0e4b992263c01638cdc422.scn"
[deps]
source_file="res://Models/moogle.gltf"
dest_files=["res://.godot/imported/moogle.gltf-cb3e71457a0e4b992263c01638cdc422.scn"]
[params]
nodes/root_type="Node3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/embedded_image_handling=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -0,0 +1,36 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://clatht61o8ysx"
path.s3tc="res://.godot/imported/moogle_texture000.png-81375ea5d6ce80c829861fd48397b3eb.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={}
[deps]
source_file="res://Models/moogle_texture000.png"
dest_files=["res://.godot/imported/moogle_texture000.png-81375ea5d6ce80c829861fd48397b3eb.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -0,0 +1,36 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://6p1sry36fbd4"
path.s3tc="res://.godot/imported/moogle_texture001.png-1591f8e33ffe1ebbb8a7f6bd4b0ff820.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={}
[deps]
source_file="res://Models/moogle_texture001.png"
dest_files=["res://.godot/imported/moogle_texture001.png-1591f8e33ffe1ebbb8a7f6bd4b0ff820.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1,36 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bdbwnm0wgkvdb"
path.s3tc="res://.godot/imported/moogle_texture002.png-89b4469a5fe7e845eede706c134be494.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={}
[deps]
source_file="res://Models/moogle_texture002.png"
dest_files=["res://.godot/imported/moogle_texture002.png-89b4469a5fe7e845eede706c134be494.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -3,4 +3,7 @@
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading> <EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Folder Include="Scenes\" />
</ItemGroup>
</Project> </Project>

View File

@@ -1,8 +1,10 @@
[gd_scene load_steps=10 format=3 uid="uid://oq32v4vt173t"] [gd_scene load_steps=13 format=3 uid="uid://bcsgd8vxy43g2"]
[ext_resource type="Script" path="res://Scripts/Player.cs" id="1_8dc05"]
[ext_resource type="PackedScene" uid="uid://d20uxkpid4ynd" path="res://Models/vivi1.gltf" id="1_mqt2m"] [ext_resource type="PackedScene" uid="uid://d20uxkpid4ynd" path="res://Models/vivi1.gltf" id="1_mqt2m"]
[ext_resource type="Script" path="res://Scripts/CharacterBody3D.cs" id="1_ry77d"] [ext_resource type="Script" path="res://Scripts/CameraSystem.cs" id="3_5ecw2"]
[ext_resource type="Script" path="res://Scenes/CameraSystem.cs" id="3_5ecw2"] [ext_resource type="PackedScene" uid="uid://c13g5orvyhy1p" path="res://Models/moogle.gltf" id="4_dckjs"]
[ext_resource type="Script" path="res://Scripts/NPCFollow.cs" id="4_o5mpp"]
[sub_resource type="BoxShape3D" id="BoxShape3D_8verc"] [sub_resource type="BoxShape3D" id="BoxShape3D_8verc"]
size = Vector3(100, 2, 100) size = Vector3(100, 2, 100)
@@ -14,6 +16,10 @@ size = Vector3(100, 2, 100)
radius = 0.3345 radius = 0.3345
height = 1.0 height = 1.0
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_xwe0t"]
radius = 21.859
height = 86.061
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_8y7we"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_8y7we"]
albedo_color = Color(0.937255, 0, 0.298039, 1) albedo_color = Color(0.937255, 0, 0.298039, 1)
@@ -37,27 +43,24 @@ mesh = SubResource("BoxMesh_0jrjy")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.770914, 0.63694, 0, -0.63694, 0.770914, 0, 19.7871, 33.6204) transform = Transform3D(1, 0, 0, 0, 0.770914, 0.63694, 0, -0.63694, 0.770914, 0, 19.7871, 33.6204)
[node name="CharacterBody3D" type="CharacterBody3D" parent="."] [node name="Player" type="CharacterBody3D" parent="."]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, -0.242191, 0) transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, -0.242191, 0)
collision_layer = 2 collision_layer = 2
script = ExtResource("1_ry77d") script = ExtResource("1_8dc05")
_sensitivityHorizontal = 0.01 _sensitivityHorizontal = 0.01
_sensitivityVertical = 0.01 _sensitivityVertical = 0.01
[node name="Pivot" type="Node3D" parent="CharacterBody3D"] [node name="Pivot" type="Node3D" parent="Player"]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 0, 0) transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 0, 0)
[node name="vivi1" parent="CharacterBody3D/Pivot" instance=ExtResource("1_mqt2m")] [node name="vivi1" parent="Player/Pivot" instance=ExtResource("1_mqt2m")]
transform = Transform3D(-0.01, 0, -8.74228e-10, 0, 0.01, 0, 8.74228e-10, 0, -0.01, 0, 0.20569, 0) transform = Transform3D(-0.01, 0, -8.74228e-10, 0, 0.01, 0, 8.74228e-10, 0, -0.01, 0, 0.20569, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="CharacterBody3D"] [node name="CollisionShape3D" type="CollisionShape3D" parent="Player"]
transform = Transform3D(1, 0, 7.10543e-15, 0, 1, 0, -7.10543e-15, 0, 1, 0, 0.690513, 0) transform = Transform3D(1, 0, 7.10543e-15, 0, 1, 0, -7.10543e-15, 0, 1, 0, 0.690513, 0)
shape = SubResource("CapsuleShape3D_v20i5") shape = SubResource("CapsuleShape3D_v20i5")
[node name="Node3D" type="Node3D" parent="CharacterBody3D"] [node name="CameraMount" type="SpringArm3D" parent="Player"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.495499, 0)
[node name="CameraMount" type="SpringArm3D" parent="CharacterBody3D"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 1.04459e-07, 1.07272, -1.19487) transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 1.04459e-07, 1.07272, -1.19487)
spring_length = 2.0 spring_length = 2.0
margin = 0.2 margin = 0.2
@@ -65,10 +68,24 @@ script = ExtResource("3_5ecw2")
_sensitivityHorizontal = 0.03 _sensitivityHorizontal = 0.03
_sensitivityVertical = 0.03 _sensitivityVertical = 0.03
[node name="Camera3D" type="Camera3D" parent="CharacterBody3D/CameraMount"] [node name="Camera3D" type="Camera3D" parent="Player/CameraMount"]
current = true current = true
far = 54.29 far = 54.29
[node name="NPC1" type="CharacterBody3D" parent="."]
transform = Transform3D(-0.01, 0, 8.74228e-10, 0, 0.01, 0, -8.74228e-10, 0, -0.01, 0, 0, 1.31191)
collision_layer = 2
script = ExtResource("4_o5mpp")
[node name="Pivot" type="Node3D" parent="NPC1"]
[node name="moogle" parent="NPC1/Pivot" instance=ExtResource("4_dckjs")]
transform = Transform3D(1, 0, -7.10543e-15, 0, 1, 0, 7.10543e-15, 0, 1, 0, 0, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="NPC1"]
transform = Transform3D(1, 0, -7.10543e-15, 0, 1, 0, 7.10543e-15, 0, 1, 0, 41.4825, 0)
shape = SubResource("CapsuleShape3D_xwe0t")
[node name="Boxes" type="Node" parent="."] [node name="Boxes" type="Node" parent="."]
[node name="CSGBox3D" type="CSGBox3D" parent="Boxes"] [node name="CSGBox3D" type="CSGBox3D" parent="Boxes"]

View File

@@ -14,8 +14,8 @@ public partial class CameraSystem : SpringArm3D
public override void _Ready() public override void _Ready()
{ {
_pivot = GetNode<Node3D>("/root/Main/CharacterBody3D/Pivot"); _pivot = GetNode<Node3D>("/root/Main/Player/Pivot");
_characterBody = GetNode<CharacterBody3D>("/root/Main/CharacterBody3D"); _characterBody = GetNode<CharacterBody3D>("/root/Main/Player");
} }
public override void _Process(double delta) public override void _Process(double delta)

32
Scripts/NPCFollow.cs Normal file
View File

@@ -0,0 +1,32 @@
using Godot;
public partial class NPCFollow : CharacterBody3D
{
[Export]
private float _speed = 5f;
[Export]
private double _followDistance = 2;
private Node3D _player;
public const float JumpVelocity = 4.5f;
public float _gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
public override void _Ready()
{
_player = GetNode<Node3D>("/root/Main/Player");
}
public override void _PhysicsProcess(double delta)
{
var playerPosition = _player.Position;
var targetPosition = (playerPosition - Position).Normalized();
if (Position.DistanceTo(playerPosition) >= _followDistance)
{
LookAt(playerPosition - Velocity, Vector3.Up);
Velocity = Velocity.Slerp(targetPosition * _speed, 0.5f);
MoveAndSlide();
}
}
}

View File

@@ -1,6 +1,6 @@
using Godot; using Godot;
public partial class CharacterBody3D : Godot.CharacterBody3D public partial class Player : CharacterBody3D
{ {
public const float Speed = 5.0f; public const float Speed = 5.0f;
public const float JumpVelocity = 4.5f; public const float JumpVelocity = 4.5f;
@@ -15,14 +15,14 @@ public partial class CharacterBody3D : Godot.CharacterBody3D
private Node3D _cameraMount; private Node3D _cameraMount;
private Node3D _pivot; private Node3D _pivot;
// Get the gravity from the project settings to be synced with RigidBody nodes. // Get the _gravity from the project settings to be synced with RigidBody nodes.
public float gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle(); public float _gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
public override void _Ready() public override void _Ready()
{ {
Input.MouseMode = Input.MouseModeEnum.Captured; Input.MouseMode = Input.MouseModeEnum.Captured;
_cameraMount = GetNode<Node3D>("/root/Main/CharacterBody3D/CameraMount"); _cameraMount = GetNode<Node3D>("/root/Main/Player/CameraMount");
_pivot = GetNode<Node3D>("/root/Main/CharacterBody3D/Pivot"); _pivot = GetNode<Node3D>("/root/Main/Player/Pivot");
} }
public override void _UnhandledInput(InputEvent @event) public override void _UnhandledInput(InputEvent @event)
@@ -35,16 +35,12 @@ public partial class CharacterBody3D : Godot.CharacterBody3D
{ {
Vector3 velocity = Velocity; Vector3 velocity = Velocity;
// Add the gravity.
if (!IsOnFloor()) if (!IsOnFloor())
velocity.Y -= gravity * (float)delta; velocity.Y -= _gravity * (float)delta;
// Handle Jump.
if (Input.IsActionJustPressed("jump") && IsOnFloor()) if (Input.IsActionJustPressed("jump") && IsOnFloor())
velocity.Y = JumpVelocity; velocity.Y = JumpVelocity;
// Get the input direction and handle the movement/deceleration.
// As good practice, you should replace UI actions with custom gameplay actions.
Vector2 inputDir = Input.GetVector("right", "left", "back", "forward"); Vector2 inputDir = Input.GetVector("right", "left", "back", "forward");
Vector3 direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized(); Vector3 direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
if (direction != Vector3.Zero) if (direction != Vector3.Zero)