Feat/3 adding playermodel #8
@@ -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)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bl23osdva6gy6
|
||||||
@@ -268,6 +268,14 @@ func _build_player() -> void:
|
|||||||
if mover_script:
|
if mover_script:
|
||||||
player.set_script(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
|
# Movement State Machine
|
||||||
var sm := Node.new()
|
var sm := Node.new()
|
||||||
sm.name = "MovementStateMachine"
|
sm.name = "MovementStateMachine"
|
||||||
|
|||||||
+10
-18
@@ -1,7 +1,7 @@
|
|||||||
extends StaticBody3D
|
extends StaticBody3D
|
||||||
class_name TargetDummy
|
class_name TargetDummy
|
||||||
|
|
||||||
var mesh_instance: MeshInstance3D
|
var visual_node: Node3D
|
||||||
var dps_label: Label3D
|
var dps_label: Label3D
|
||||||
|
|
||||||
# Array of dictionaries: { "time": float, "amount": float }
|
# Array of dictionaries: { "time": float, "amount": float }
|
||||||
@@ -18,19 +18,11 @@ func _ready() -> void:
|
|||||||
shape.position = Vector3(0, 1.0, 0)
|
shape.position = Vector3(0, 1.0, 0)
|
||||||
add_child(shape)
|
add_child(shape)
|
||||||
|
|
||||||
# Mesh
|
# Humanoid Model
|
||||||
mesh_instance = MeshInstance3D.new()
|
visual_node = load("res://characters/humanoid_model.gd").new()
|
||||||
var mesh = CapsuleMesh.new()
|
visual_node.name = "HumanoidModel"
|
||||||
mesh.radius = 0.5
|
visual_node.color = Color(0.8, 0.2, 0.2)
|
||||||
mesh.height = 2.0
|
add_child(visual_node)
|
||||||
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)
|
|
||||||
|
|
||||||
# DPS Label
|
# DPS Label
|
||||||
dps_label = Label3D.new()
|
dps_label = Label3D.new()
|
||||||
@@ -75,11 +67,11 @@ func _update_dps() -> void:
|
|||||||
func _wiggle() -> void:
|
func _wiggle() -> void:
|
||||||
# Small tween to shake the dummy
|
# Small tween to shake the dummy
|
||||||
var tween = create_tween()
|
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))
|
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(visual_node, "position", orig_pos + wiggle_dir, 0.05)
|
||||||
tween.tween_property(mesh_instance, "position", orig_pos - wiggle_dir, 0.05)
|
tween.tween_property(visual_node, "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, 0.05)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user