hold right+left, it charges ahead
This commit is contained in:
@@ -14,9 +14,11 @@ const HOOF_OFFSETS: Array = [
|
||||
var _hoof_emitters: Array[CPUParticles3D] = []
|
||||
var _legs: Node
|
||||
|
||||
var _kick_timer: float = 0.0
|
||||
var _was_on_floor: bool = false
|
||||
var _kick_timer: float = 0.0
|
||||
var _was_on_floor: bool = false
|
||||
var _pre_slide_vel_y: float = 0.0
|
||||
var _charge_dir: Vector3 = Vector3.ZERO
|
||||
var _both_held: bool = false
|
||||
|
||||
enum DustState { NONE, WALK, CHARGE }
|
||||
var _dust_state: DustState = DustState.NONE
|
||||
@@ -177,18 +179,42 @@ func _physics_process(delta: float) -> void:
|
||||
var charging := Input.is_action_pressed(&"charge")
|
||||
var on_floor := is_on_floor()
|
||||
|
||||
# ── Left / right click thrust ─────────────────────────────────────────────
|
||||
# Left click → thrust NE (forward-right diagonal)
|
||||
# Right click → thrust NW (forward-left diagonal)
|
||||
if Input.is_action_just_pressed(&"thrust_left") or Input.is_action_just_pressed(&"thrust_right"):
|
||||
# ── Mouse button actions ──────────────────────────────────────────────────
|
||||
# Both held → charge: lock direction, ramp speed, lower head
|
||||
# Left only → thrust NE (forward-right diagonal)
|
||||
# Right only → thrust NW (forward-left diagonal)
|
||||
var left_held := Input.is_action_pressed(&"thrust_left")
|
||||
var right_held := Input.is_action_pressed(&"thrust_right")
|
||||
var both_held := left_held and right_held
|
||||
|
||||
if both_held and not _both_held:
|
||||
var raw := cube_guy.global_transform.basis.z
|
||||
var bull_fwd := Vector3(raw.x, 0.0, raw.z).normalized()
|
||||
var bull_right := bull_fwd.cross(Vector3.UP)
|
||||
if Input.is_action_just_pressed(&"thrust_left"):
|
||||
_charge_dir = Vector3(raw.x, 0.0, raw.z).normalized()
|
||||
|
||||
if both_held:
|
||||
velocity.x += _charge_dir.x * DP.f("bull_charge_accel") * delta
|
||||
velocity.z += _charge_dir.z * DP.f("bull_charge_accel") * delta
|
||||
var flat_c := Vector2(velocity.x, velocity.z)
|
||||
var spd_c := flat_c.length()
|
||||
if spd_c > DP.f("bull_charge_max_speed"):
|
||||
velocity.x *= DP.f("bull_charge_max_speed") / spd_c
|
||||
velocity.z *= DP.f("bull_charge_max_speed") / spd_c
|
||||
_legs.set(&"charge_pitch_target", DP.f("charge_head_pitch"))
|
||||
else:
|
||||
_legs.set(&"charge_pitch_target", 0.0)
|
||||
if Input.is_action_just_pressed(&"thrust_left") and not right_held:
|
||||
var raw := cube_guy.global_transform.basis.z
|
||||
var bull_fwd := Vector3(raw.x, 0.0, raw.z).normalized()
|
||||
var bull_right := bull_fwd.cross(Vector3.UP)
|
||||
_apply_thrust((bull_fwd + bull_right).normalized())
|
||||
else:
|
||||
elif Input.is_action_just_pressed(&"thrust_right") and not left_held:
|
||||
var raw := cube_guy.global_transform.basis.z
|
||||
var bull_fwd := Vector3(raw.x, 0.0, raw.z).normalized()
|
||||
var bull_right := bull_fwd.cross(Vector3.UP)
|
||||
_apply_thrust((bull_fwd - bull_right).normalized())
|
||||
|
||||
_both_held = both_held
|
||||
|
||||
# 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
|
||||
@@ -196,7 +222,7 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
# ── Periodic kick ─────────────────────────────────────────────────────────
|
||||
_kick_timer = maxf(0.0, _kick_timer - delta)
|
||||
if direction and _kick_timer <= 0.0:
|
||||
if direction and _kick_timer <= 0.0 and not both_held:
|
||||
_apply_kick(direction, charging)
|
||||
_kick_timer = DP.f("kick_interval")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user