Skip to content

Commit

Permalink
Player Mesh + Animations
Browse files Browse the repository at this point in the history
  • Loading branch information
Blockitifluy committed Aug 1, 2024
1 parent a797d53 commit d21caa0
Show file tree
Hide file tree
Showing 38 changed files with 2,574 additions and 26 deletions.
18 changes: 17 additions & 1 deletion Characters/BasicCharacter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
[GlobalClass]
public abstract partial class BasicCharacter : CharacterBody3D
{
public enum State
{
Idle,
Walking,
Wandering,
Chasing,
Attacking
}

/// <summary>
/// The fall acceleration of character
/// </summary>
Expand All @@ -14,6 +23,8 @@ public abstract partial class BasicCharacter : CharacterBody3D
/// </summary>
[Export(PropertyHint.Range, "0,1,")] public float LookWeight { get; set; } = 0.25f;

[Export] public State CurrentState { get; set; } = State.Idle;

/// <summary>
/// The base walk speed
/// </summary>
Expand Down Expand Up @@ -170,7 +181,12 @@ public float RunAction(double delta)

TargetVelocity = velo;

if (velo != Vector3.Zero) Pivot.Basis = lookAt;
if (velo != Vector3.Zero)
{
Pivot.Basis = lookAt;
CurrentState = State.Walking;
}
else CurrentState = State.Idle;

float runStamina = SpeedToStamina(velo.Length());

Expand Down
21 changes: 21 additions & 0 deletions Characters/Player/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public partial class Player : BasicCharacter

private Marker3D Grip;
private Marker3D CameraPivot;
private AnimationPlayer Animator;

private Animation WalkAnim;

private const string WalkAnimName = "Walk";
private const string IdleAnimName = "Idle";

public override bool IsRunning()
{
Expand Down Expand Up @@ -226,6 +232,9 @@ public override void _Ready()

Grip = GetNode<Marker3D>("Pivot/Grip");
CameraPivot = (Marker3D)GetTree().GetFirstNodeInGroup("CameraPivot");
Animator = this.GetChildByType<AnimationPlayer>();

WalkAnim = Animator.GetAnimation(WalkAnimName);

Inventory.InventoryItem axe = inventory.AddItem(Items.ItemCode.Axe, 1);
Hotbar.AddToFromHotbar(axe, 0);
Expand All @@ -241,6 +250,18 @@ public override void _Process(double delta)
PickupAction(delta);
EquipAction();

if (CurrentState == State.Walking)
{
float speed = GetSpeed(),
animSpeed = speed / WalkAnim.Length / 15.0f;

Animator.Play(WalkAnimName, .5d, animSpeed);
}
else if (CurrentState == State.Idle)
{
Animator.Play(IdleAnimName, .5d);
}

PickupTimer += delta;
}

Expand Down
Binary file added Characters/Player/Textures/char_color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions Characters/Player/Textures/char_color.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://b4n8fu1o7yjha"
path.s3tc="res://.godot/imported/char_color.png-63cfc091213caf8752fdba977cbe10bc.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}

[deps]

source_file="res://Characters/Player/Textures/char_color.png"
dest_files=["res://.godot/imported/char_color.png-63cfc091213caf8752fdba977cbe10bc.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 added Characters/Player/Textures/char_rough.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions Characters/Player/Textures/char_rough.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bk7x3d880fjjw"
path.s3tc="res://.godot/imported/char_rough.png-92116cbfc36d493cd9f530173a2e66aa.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}

[deps]

source_file="res://Characters/Player/Textures/char_rough.png"
dest_files=["res://.godot/imported/char_rough.png-92116cbfc36d493cd9f530173a2e66aa.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 added Characters/Player/Textures/char_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Characters/Player/Textures/char_text.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cojca1ynfie0q"
path="res://.godot/imported/char_text.png-85bd2e6dffbf29bccaaf8ecfcfb73974.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Characters/Player/Textures/char_text.png"
dest_files=["res://.godot/imported/char_text.png-85bd2e6dffbf29bccaaf8ecfcfb73974.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
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=1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions Characters/Player/Textures/character_char_color.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://c35sjsrwsfryh"
path.s3tc="res://.godot/imported/character_char_color.png-8c809c1a7aa73cabc81b23da1ca9fc10.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "abec0162d8621c289cd3aeb4893e8ef3"
}

[deps]

source_file="res://Characters/Player/Textures/character_char_color.png"
dest_files=["res://.godot/imported/character_char_color.png-8c809c1a7aa73cabc81b23da1ca9fc10.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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions Characters/Player/Textures/character_char_rough.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://d1w35wp72lgw7"
path.s3tc="res://.godot/imported/character_char_rough.png-6454059bc6c9a64305f58e46cd04e675.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "f57038267beb531fc9e5d999d564d1d8"
}

[deps]

source_file="res://Characters/Player/Textures/character_char_rough.png"
dest_files=["res://.godot/imported/character_char_rough.png-6454059bc6c9a64305f58e46cd04e675.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 added Characters/Player/Textures/player_char_color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions Characters/Player/Textures/player_char_color.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://b4my7ggj4qv2u"
path.s3tc="res://.godot/imported/player_char_color.png-d5c17cf67bedb8b1aca8fd6a68ea5e75.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "abec0162d8621c289cd3aeb4893e8ef3"
}

[deps]

source_file="res://Characters/Player/Textures/player_char_color.png"
dest_files=["res://.godot/imported/player_char_color.png-d5c17cf67bedb8b1aca8fd6a68ea5e75.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 added Characters/Player/Textures/player_char_rough.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions Characters/Player/Textures/player_char_rough.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dn0um1mr10q4i"
path.s3tc="res://.godot/imported/player_char_rough.png-13705bbda89ec190cacc6ede63246e41.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "f57038267beb531fc9e5d999d564d1d8"
}

[deps]

source_file="res://Characters/Player/Textures/player_char_rough.png"
dest_files=["res://.godot/imported/player_char_rough.png-13705bbda89ec190cacc6ede63246e41.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 added Characters/Player/character.glb
Binary file not shown.
34 changes: 34 additions & 0 deletions Characters/Player/character.glb.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="scene"
importer_version=1
type="PackedScene"
uid="uid://c8i364q25tknx"
path="res://.godot/imported/character.glb-758168fa14fdad8867234663c81288ec.scn"

[deps]

source_file="res://Characters/Player/character.glb"
dest_files=["res://.godot/imported/character.glb-758168fa14fdad8867234663c81288ec.scn"]

[params]

nodes/root_type=""
nodes/root_name=""
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
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1
12 changes: 12 additions & 0 deletions Characters/Player/player.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Blender 4.2.0 MTL File: 'character.blend'
# www.blender.org

newmtl char_mat
Ka 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd char_color.png
map_Ns char_rough.png
Loading

0 comments on commit d21caa0

Please sign in to comment.