feat: humanoid player model without animations

This commit is contained in:
DottsGit
2026-06-05 13:37:43 -04:00
parent 1e1568f748
commit 72346803a9
4 changed files with 91 additions and 18 deletions
+72
View File
@@ -0,0 +1,72 @@
extends Node3D
class_name HumanoidModel
@export var color: Color = Color.WHITE
@export var shadows_only: bool = false
var torso: MeshInstance3D
var head: MeshInstance3D
var arm_l: MeshInstance3D
var arm_r: MeshInstance3D
var leg_l: MeshInstance3D
var leg_r: MeshInstance3D
# Simple programmatic humanoid
func _ready() -> void:
var mat := StandardMaterial3D.new()
mat.albedo_color = color
mat.roughness = 0.8
var shadow_setting = GeometryInstance3D.SHADOW_CASTING_SETTING_SHADOWS_ONLY if shadows_only else GeometryInstance3D.SHADOW_CASTING_SETTING_ON
# Torso
torso = MeshInstance3D.new()
var t_mesh = BoxMesh.new()
t_mesh.size = Vector3(0.4, 0.7, 0.25)
t_mesh.material = mat
torso.mesh = t_mesh
torso.position = Vector3(0, 1.15, 0)
torso.cast_shadow = shadow_setting
add_child(torso)
# Head
head = MeshInstance3D.new()
var h_mesh = BoxMesh.new()
h_mesh.size = Vector3(0.25, 0.25, 0.25)
h_mesh.material = mat
head.mesh = h_mesh
head.position = Vector3(0, 1.65, 0)
head.cast_shadow = shadow_setting
add_child(head)
# Arms
arm_l = MeshInstance3D.new()
var a_mesh = BoxMesh.new()
a_mesh.size = Vector3(0.12, 0.65, 0.12)
a_mesh.material = mat
arm_l.mesh = a_mesh
arm_l.position = Vector3(-0.28, 1.15, 0)
arm_l.cast_shadow = shadow_setting
add_child(arm_l)
arm_r = MeshInstance3D.new()
arm_r.mesh = a_mesh
arm_r.position = Vector3(0.28, 1.15, 0)
arm_r.cast_shadow = shadow_setting
add_child(arm_r)
# Legs
leg_l = MeshInstance3D.new()
var l_mesh = BoxMesh.new()
l_mesh.size = Vector3(0.15, 0.8, 0.15)
l_mesh.material = mat
leg_l.mesh = l_mesh
leg_l.position = Vector3(-0.12, 0.4, 0)
leg_l.cast_shadow = shadow_setting
add_child(leg_l)
leg_r = MeshInstance3D.new()
leg_r.mesh = l_mesh
leg_r.position = Vector3(0.12, 0.4, 0)
leg_r.cast_shadow = shadow_setting
add_child(leg_r)
+1
View File
@@ -0,0 +1 @@
uid://bl23osdva6gy6
+8
View File
@@ -267,6 +267,14 @@ func _build_player() -> void:
var mover_script = preload("res://movement/player_movement_controller.gd")
if mover_script:
player.set_script(mover_script)
# Humanoid Model for Player (Shadows only so it doesn't clip with camera)
var humanoid = load("res://characters/humanoid_model.gd").new()
humanoid.name = "HumanoidModel"
humanoid.color = Color(0.2, 0.4, 0.8) # Blueish for player
humanoid.shadows_only = true
humanoid.position = Vector3(0, -0.9, 0) # Offset from center to feet
player.add_child(humanoid)
# Movement State Machine
var sm := Node.new()
+10 -18
View File
@@ -1,7 +1,7 @@
extends StaticBody3D
class_name TargetDummy
var mesh_instance: MeshInstance3D
var visual_node: Node3D
var dps_label: Label3D
# Array of dictionaries: { "time": float, "amount": float }
@@ -18,19 +18,11 @@ func _ready() -> void:
shape.position = Vector3(0, 1.0, 0)
add_child(shape)
# Mesh
mesh_instance = MeshInstance3D.new()
var mesh = CapsuleMesh.new()
mesh.radius = 0.5
mesh.height = 2.0
mesh_instance.mesh = mesh
var mat = StandardMaterial3D.new()
mat.albedo_color = Color(0.8, 0.2, 0.2) # Red dummy
mat.roughness = 0.7
mesh.material = mat
mesh_instance.position = Vector3(0, 1.0, 0)
add_child(mesh_instance)
# Humanoid Model
visual_node = load("res://characters/humanoid_model.gd").new()
visual_node.name = "HumanoidModel"
visual_node.color = Color(0.8, 0.2, 0.2)
add_child(visual_node)
# DPS Label
dps_label = Label3D.new()
@@ -75,11 +67,11 @@ func _update_dps() -> void:
func _wiggle() -> void:
# Small tween to shake the dummy
var tween = create_tween()
var orig_pos = Vector3(0, 1.0, 0)
var orig_pos = Vector3.ZERO
var wiggle_dir = Vector3(randf_range(-0.1, 0.1), 0, randf_range(-0.1, 0.1))
tween.tween_property(mesh_instance, "position", orig_pos + wiggle_dir, 0.05)
tween.tween_property(mesh_instance, "position", orig_pos - wiggle_dir, 0.05)
tween.tween_property(mesh_instance, "position", orig_pos, 0.05)
tween.tween_property(visual_node, "position", orig_pos + wiggle_dir, 0.05)
tween.tween_property(visual_node, "position", orig_pos - wiggle_dir, 0.05)
tween.tween_property(visual_node, "position", orig_pos, 0.05)