feat: humanoid player model without animations
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user