matadors moving, thrusty bull, slop
This commit is contained in:
@@ -13,7 +13,6 @@ const HOOF_OFFSETS: Array = [
|
||||
|
||||
var _hoof_emitters: Array[CPUParticles3D] = []
|
||||
var _legs: Node
|
||||
var _debug_shapes: Array[MeshInstance3D] = []
|
||||
|
||||
var _kick_timer: float = 0.0
|
||||
var _was_on_floor: bool = false
|
||||
@@ -24,10 +23,10 @@ var _dust_state: _DustState = _DustState.NONE
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group(&"player")
|
||||
_setup_hoof_dust()
|
||||
_setup_legs()
|
||||
DP.any_changed.connect(_on_dp_changed)
|
||||
_sync_debug_vis()
|
||||
|
||||
|
||||
func _setup_legs() -> void:
|
||||
@@ -109,10 +108,7 @@ func _set_dust_state(new_state: _DustState) -> void:
|
||||
p.emitting = true
|
||||
|
||||
|
||||
func _on_dp_changed(key: String, _val: Variant) -> void:
|
||||
if key == "show_collisions" or key == "__all__":
|
||||
_sync_debug_vis()
|
||||
|
||||
func _on_dp_changed(_key: String, _val: Variant) -> void:
|
||||
if _hoof_emitters.is_empty() or _dust_state == _DustState.NONE:
|
||||
return
|
||||
var prev := _dust_state
|
||||
@@ -120,41 +116,20 @@ func _on_dp_changed(key: String, _val: Variant) -> void:
|
||||
_set_dust_state(prev)
|
||||
|
||||
|
||||
func _sync_debug_vis() -> void:
|
||||
_clear_debug_vis()
|
||||
if not DP.b("show_collisions"):
|
||||
return
|
||||
|
||||
# Material for wireframes
|
||||
var mat := StandardMaterial3D.new()
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.no_depth_test = true
|
||||
mat.albedo_color = Color(0, 1, 0, 0.5)
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
|
||||
# Find all collision shapes in self and children
|
||||
_create_debug_meshes(self, mat)
|
||||
|
||||
|
||||
func _create_debug_meshes(node: Node, mat: Material) -> void:
|
||||
if node is CollisionShape3D and node.shape:
|
||||
var mi := MeshInstance3D.new()
|
||||
mi.mesh = node.shape.get_debug_mesh()
|
||||
mi.material_override = mat
|
||||
# We add it as child of the collision shape to follow its transform
|
||||
node.add_child(mi)
|
||||
_debug_shapes.append(mi)
|
||||
|
||||
for child in node.get_children():
|
||||
_create_debug_meshes(child, mat)
|
||||
|
||||
|
||||
func _clear_debug_vis() -> void:
|
||||
for mi in _debug_shapes:
|
||||
if is_instance_valid(mi):
|
||||
mi.get_parent().remove_child(mi)
|
||||
mi.queue_free()
|
||||
_debug_shapes.clear()
|
||||
func _apply_thrust(dir: Vector3) -> void:
|
||||
var impulse := DP.f("thrust_impulse")
|
||||
velocity.x += dir.x * impulse
|
||||
velocity.z += dir.z * impulse
|
||||
if is_on_floor():
|
||||
velocity.y += DP.f("thrust_vertical")
|
||||
var flat := Vector2(velocity.x, velocity.z)
|
||||
var spd := flat.length()
|
||||
if spd > DP.f("max_speed"):
|
||||
var s := DP.f("max_speed") / spd
|
||||
velocity.x *= s
|
||||
velocity.z *= s
|
||||
|
||||
|
||||
func _apply_kick(direction: Vector3, charging: bool) -> void:
|
||||
@@ -202,6 +177,17 @@ func _physics_process(delta: float) -> void:
|
||||
var charging := Input.is_action_pressed(&"charge")
|
||||
var on_floor := is_on_floor()
|
||||
|
||||
# ── Left / right click thrust (only when mouse is captured) ─────────────
|
||||
# Left click → thrust NE (forward-right diagonal)
|
||||
# Right click → thrust NW (forward-left diagonal)
|
||||
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
if Input.is_action_just_pressed(&"thrust_left"):
|
||||
var ne := (flat_forward + flat_right).normalized()
|
||||
_apply_thrust(ne if ne.length() > 0.1 else flat_forward)
|
||||
if Input.is_action_just_pressed(&"thrust_right"):
|
||||
var nw := (flat_forward - flat_right).normalized()
|
||||
_apply_thrust(nw if nw.length() > 0.1 else flat_forward)
|
||||
|
||||
# Reset kick timer on landing so the first kick after a bounce is immediate
|
||||
if on_floor and not _was_on_floor and direction:
|
||||
_kick_timer = 0.0
|
||||
|
||||
Reference in New Issue
Block a user