Improved animations

This commit is contained in:
Michel 2025-02-01 12:53:22 +01:00
parent ab3890896d
commit cf8ba8bacb
34 changed files with 25503 additions and 4869 deletions

View file

@ -16,7 +16,6 @@ roughness_texture = ExtResource("4_ptq0i")
normal_enabled = true normal_enabled = true
normal_scale = 2.89 normal_scale = 2.89
normal_texture = ExtResource("3_24st2") normal_texture = ExtResource("3_24st2")
heightmap_enabled = true
heightmap_scale = 0.697 heightmap_scale = 0.697
heightmap_texture = ExtResource("2_p176y") heightmap_texture = ExtResource("2_p176y")
heightmap_flip_texture = true heightmap_flip_texture = true

View file

@ -1,13 +1,13 @@
[gd_resource type="AnimationNodeBlendSpace1D" load_steps=4 format=3 uid="uid://belbtf6saao12"] [gd_resource type="AnimationNodeBlendSpace1D" load_steps=4 format=3 uid="uid://belbtf6saao12"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_fw2oo"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_fw2oo"]
animation = &"LVA4_Armature|Fire_1" animation = &"LVA4_Armature_Fire_1"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_up73k"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_up73k"]
animation = &"LVA4_Armature|Fire_2" animation = &"LVA4_Armature_Fire_2"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_bjhpv"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_bjhpv"]
animation = &"LVA4_Armature|Fire_3" animation = &"LVA4_Armature_Fire_3"
[resource] [resource]
blend_point_0/node = SubResource("AnimationNodeAnimation_fw2oo") blend_point_0/node = SubResource("AnimationNodeAnimation_fw2oo")

View file

@ -1,21 +1,24 @@
[gd_resource type="AnimationNodeBlendSpace2D" load_steps=6 format=3 uid="uid://dh5bnb5xvmv0f"] [gd_resource type="AnimationNodeBlendSpace2D" load_steps=7 format=3 uid="uid://dh5bnb5xvmv0f"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_glk57"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_glk57"]
animation = &"LVA4_Armature|Idle" animation = &"LVA4_Armature_Idle"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_4nam8"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_4nam8"]
animation = &"LVA4_Armature|Move_Forward" animation = &"LVA4_Armature_Move_Forward"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_y7e77"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_y7e77"]
animation = &"LVA4_Armature|Move_Left" animation = &"LVA4_Armature_Move_Left"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_hwjyc"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_hwjyc"]
animation = &"LVA4_Armature|Move_Right" animation = &"LVA4_Armature_Courched_Move_Right"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_owips"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_owips"]
animation = &"LVA4_Armature|Move_Forward" animation = &"LVA4_Armature_Move_Forward"
play_mode = 1 play_mode = 1
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_hmil4"]
animation = &"LVA4_Armature_Sprint_Forward"
[resource] [resource]
blend_point_0/node = SubResource("AnimationNodeAnimation_glk57") blend_point_0/node = SubResource("AnimationNodeAnimation_glk57")
blend_point_0/pos = Vector2(0, 0) blend_point_0/pos = Vector2(0, 0)
@ -27,3 +30,6 @@ blend_point_3/node = SubResource("AnimationNodeAnimation_hwjyc")
blend_point_3/pos = Vector2(-1, 0) blend_point_3/pos = Vector2(-1, 0)
blend_point_4/node = SubResource("AnimationNodeAnimation_owips") blend_point_4/node = SubResource("AnimationNodeAnimation_owips")
blend_point_4/pos = Vector2(0, -1) blend_point_4/pos = Vector2(0, -1)
blend_point_5/node = SubResource("AnimationNodeAnimation_hmil4")
blend_point_5/pos = Vector2(0, 2)
max_space = Vector2(1, 2)

BIN
content/rifle/hk437.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c6bunpewcofd"
path.s3tc="res://.godot/imported/hk437.png-55df770db05b5219b5a216e050ef39cf.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://content/rifle/hk437.png"
dest_files=["res://.godot/imported/hk437.png-55df770db05b5219b5a216e050ef39cf.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

BIN
content/rifle/hk437.png~ Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

View file

@ -1,14 +1,27 @@
[gd_resource type="StandardMaterial3D" load_steps=6 format=3 uid="uid://bmawvuomui06g"] [gd_resource type="StandardMaterial3D" load_steps=8 format=3 uid="uid://bmawvuomui06g"]
[ext_resource type="Texture2D" uid="uid://dnavx8bsrg2cp" path="res://content/rifle/Cardboard001_2K-PNG/Cardboard001_2K-PNG_Color.png" id="1_1k1j1"] [ext_resource type="Texture2D" uid="uid://dnavx8bsrg2cp" path="res://content/rifle/Cardboard001_2K-PNG/Cardboard001_2K-PNG_Color.png" id="1_1k1j1"]
[ext_resource type="Texture2D" uid="uid://w1qjoj4t60pe" path="res://content/rifle/Cardboard001_2K-PNG/Cardboard001_2K-PNG_Displacement.png" id="2_hlgs7"] [ext_resource type="Texture2D" uid="uid://w1qjoj4t60pe" path="res://content/rifle/Cardboard001_2K-PNG/Cardboard001_2K-PNG_Displacement.png" id="2_hlgs7"]
[ext_resource type="Texture2D" uid="uid://dku7f5fijokpn" path="res://content/rifle/Cardboard001_2K-PNG/Cardboard001_2K-PNG_NormalGL.png" id="3_djy0y"] [ext_resource type="Texture2D" uid="uid://dku7f5fijokpn" path="res://content/rifle/Cardboard001_2K-PNG/Cardboard001_2K-PNG_NormalGL.png" id="3_djy0y"]
[ext_resource type="Texture2D" uid="uid://cpmhd8ni4r5lu" path="res://content/rifle/Cardboard001_2K-PNG/Cardboard001_2K-PNG_Roughness.png" id="4_a4f6v"] [ext_resource type="Texture2D" uid="uid://cpmhd8ni4r5lu" path="res://content/rifle/Cardboard001_2K-PNG/Cardboard001_2K-PNG_Roughness.png" id="4_a4f6v"]
[ext_resource type="Texture2D" uid="uid://c6bunpewcofd" path="res://content/rifle/hk437.png" id="4_ebxha"]
[sub_resource type="CurveTexture" id="CurveTexture_oq5c5"] [sub_resource type="CurveTexture" id="CurveTexture_oq5c5"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_e1on6"]
render_priority = 1
transparency = 2
alpha_scissor_threshold = 0.5
alpha_antialiasing_mode = 0
albedo_texture = ExtResource("4_ebxha")
roughness_texture = ExtResource("4_a4f6v")
normal_enabled = true
normal_texture = ExtResource("3_djy0y")
heightmap_texture = ExtResource("2_hlgs7")
[resource] [resource]
albedo_color = Color(0.31, 0.31, 0.31, 1) next_pass = SubResource("StandardMaterial3D_e1on6")
albedo_color = Color(0.389287, 0.389287, 0.389287, 1)
albedo_texture = ExtResource("1_1k1j1") albedo_texture = ExtResource("1_1k1j1")
metallic_specular = 0.02 metallic_specular = 0.02
roughness_texture = ExtResource("4_a4f6v") roughness_texture = ExtResource("4_a4f6v")

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

11
credits.md Normal file
View file

@ -0,0 +1,11 @@
---
id: credits
aliases: []
tags: []
---
Low-poly Viewmodel Arms V4 for Blender by Hozq
https://hozq3d.gumroad.com/l/LVA4
HK437 - Heckler & Koch (pls don't sue me)
https://www.heckler-koch.com/en/Products/Military%20and%20Law%20Enforcement/Assault%20rifles/HK437

View file

@ -17,17 +17,17 @@ script = ExtResource("1_1tqna")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = SubResource("CylinderShape3D_w4dyg") shape = SubResource("CylinderShape3D_w4dyg")
[node name="Camera3D" type="Camera3D" parent="." node_paths=PackedStringArray("PlayerNode")] [node name="Camera3D" type="Camera3D" parent="CollisionShape3D" node_paths=PackedStringArray("PlayerNode")]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 1.68094, 0) transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 0.68094, 0)
keep_aspect = 0 keep_aspect = 0
fov = 80.0 fov = 80.0
script = ExtResource("1_v2q4i") script = ExtResource("1_v2q4i")
PlayerNode = NodePath("..") PlayerNode = NodePath("../..")
[node name="Weapon" parent="Camera3D" instance=ExtResource("3_5cmgy")] [node name="Weapon" parent="CollisionShape3D/Camera3D" instance=ExtResource("3_5cmgy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.096244, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0655423, 0)
script = ExtResource("4_nfpgt") script = ExtResource("4_nfpgt")
[node name="CooldownTimer" type="Timer" parent="Camera3D/Weapon"] [node name="CooldownTimer" type="Timer" parent="CollisionShape3D/Camera3D/Weapon"]
wait_time = 0.3 wait_time = 0.3
one_shot = true one_shot = true

View file

@ -52,6 +52,16 @@ player_shoot={
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(83, 17),"global_position":Vector2(92, 63),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null) "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(83, 17),"global_position":Vector2(92, 63),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
] ]
} }
player_sprint={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
player_crouching={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
[rendering] [rendering]

View file

@ -1,16 +1,31 @@
extends CharacterBody3D extends CharacterBody3D
@onready var animationtree: AnimationTree = $Camera3D/Weapon/AnimationPlayer/AnimationTree class_name Player
enum PlayerStates {
STANDING,
CROUCHING,
SPRINTING
}
static var Instance: Player;
@onready var animationtree: AnimationTree = $CollisionShape3D/Camera3D/Weapon/AnimationPlayer/AnimationTree
@onready var collisionShape: CollisionShape3D = $CollisionShape3D
const SPEED: float = 5.0 const SPEED: float = 5.0
const SPRINT_SPEED: float = 10.0
const FALLOFF_SPEED: float = 0.5 const FALLOFF_SPEED: float = 0.5
const JUMP_VELOCITY: float = 4.5 const JUMP_VELOCITY: float = 4.5
var lastDirection = Vector2(0,0) var lastDirection = Vector2(0,0)
@export var PlayerState: PlayerStates = PlayerStates.STANDING
# 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.
var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity") var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")
func _ready() -> void:
Instance = self
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
# Add the gravity. # Add the gravity.
@ -30,15 +45,42 @@ func _physics_process(delta: float) -> void:
if not is_on_floor(): if not is_on_floor():
falloffSpeed = 0.02; falloffSpeed = 0.02;
var speed = SPEED;
self.handleCrouching()
if PlayerState == PlayerStates.STANDING && Input.is_action_pressed('player_sprint'):
self.PlayerState = PlayerStates.SPRINTING
if PlayerState == PlayerStates.SPRINTING && Input.is_action_just_released('player_sprint'):
self.PlayerState = PlayerStates.STANDING
if PlayerState == PlayerStates.SPRINTING:
speed = SPRINT_SPEED
if direction: if direction:
velocity.x = direction.x * SPEED velocity.x = direction.x * speed
velocity.z = direction.z * SPEED velocity.z = direction.z * speed
else: else:
velocity.x = move_toward(velocity.x, 0, falloffSpeed) velocity.x = move_toward(velocity.x, 0, falloffSpeed)
velocity.z = move_toward(velocity.z, 0, falloffSpeed) velocity.z = move_toward(velocity.z, 0, falloffSpeed)
move_and_slide() move_and_slide()
if self.PlayerState == PlayerStates.SPRINTING:
input_dir.y *= 2
var blendProperty = 'parameters/Movement/blend_position'
if PlayerState == PlayerStates.CROUCHING:
blendProperty = 'parameters/Crouched Movement/blend_position'
lastDirection.x = move_toward(lastDirection.x, input_dir.x, 0.05); lastDirection.x = move_toward(lastDirection.x, input_dir.x, 0.05);
lastDirection.y = move_toward(lastDirection.y, input_dir.y, 0.05); lastDirection.y = move_toward(lastDirection.y, input_dir.y, 0.05);
animationtree.set('parameters/Movement/blend_position', lastDirection); animationtree.set(blendProperty, lastDirection);
func handleCrouching():
if Input.is_action_just_pressed('player_crouching'):
self.PlayerState = PlayerStates.CROUCHING
(collisionShape.shape as CylinderShape3D).height = 1
self.animationtree['parameters/playback'].travel('Crouched Movement')
if Input.is_action_just_released('player_crouching'):
self.PlayerState = PlayerStates.STANDING
(collisionShape.shape as CylinderShape3D).height = 2
self.animationtree['parameters/playback'].travel('Movement')

View file

@ -19,7 +19,11 @@ func _input(event: InputEvent) -> void:
if self.timer.time_left > 0: if self.timer.time_left > 0:
return return
self.animationtree.set('parameters/Fire/blend_position', randf_range(0, 2)) var travelTarget = 'Fire'
self.statemachine.travel('Fire') if Player.Instance.PlayerState == Player.PlayerStates.CROUCHING:
travelTarget = 'Crouched Fire'
self.animationtree.set('parameters/' + travelTarget + '/blend_position', randf_range(0, 2))
self.statemachine.travel(travelTarget)
self.timer.start() self.timer.start()