Reorganize the codebase into role-based folders (snake_case)
Move the 40-odd root-level scripts and scenes into a tree that groups by role,
per the approved roadmap (WS2/WS3): actors/{player,matador,bear}, systems/{combat,
fx,input,debug,render,crowd,config}, ui/, props/ (was tscn_s/). Rename the shell
scene.tscn -> levels/game_shell.tscn and every PascalCase scene to snake_case
(Player.tscn -> player.tscn, MainMenu.tscn -> main_menu.tscn, etc.) so the
case-insensitive web/macOS filesystems can't alias two files together.
Done as a scripted move: each file travels with its .uid; every quoted res:// path
across scenes, scripts, .tres, and project.godot's 9 autoloads is rewritten; the
.godot uid/class cache is rebuilt from scratch. Scenes still resolve by uid, so the
rewrite is belt-and-suspenders. Lint globs (run_tests.sh + both CI workflows) now
walk the new dirs; an orphan animation_tree.gd.uid and 7 pre-existing trailing-
whitespace lints (barrel/torch, never covered by the old root-only glob) are cleaned.
Full suite green on both sides. Asset consolidation (Assets/Animations/fonts ->
art/) is deferred — moving imported .glb/.png/.ttf is safer done in the editor.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017KoYBYQgRyY1zDHXMsXY3V
This commit is contained in:
+1110
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
uid://cn7fhjkro7637
|
||||
@@ -0,0 +1,44 @@
|
||||
[gd_scene format=3 uid="uid://o8ocjfprxa7u"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cn7fhjkro7637" path="res://actors/bear/bear.gd" id="1_beargd"]
|
||||
[ext_resource type="PackedScene" uid="uid://cofv5dbavesis" path="res://Assets/Bear.glb" id="2_bearglb"]
|
||||
[ext_resource type="PackedScene" uid="uid://bdbx0wwa73rhp" path="res://Assets/fx/Bear_FX.glb" id="3_bearfx"]
|
||||
[ext_resource type="Material" uid="uid://blpkmyikjnhbo" path="res://Materials/M_bear_claw_fx.tres" id="4_clawfx"]
|
||||
[ext_resource type="PackedScene" path="res://actors/bear/bear_attack_hitboxes.tscn" id="5_hitboxes"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_body"]
|
||||
radius = 1.0
|
||||
height = 2.4
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_hit"]
|
||||
radius = 1.3
|
||||
height = 2.7
|
||||
|
||||
[node name="Bear" type="CharacterBody3D" unique_id=1573237287]
|
||||
script = ExtResource("1_beargd")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=830443382]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.2, 0)
|
||||
shape = SubResource("CapsuleShape3D_body")
|
||||
|
||||
[node name="HitArea" type="Area3D" parent="." unique_id=365327397]
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="HitArea" unique_id=2111867348]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.35, 0)
|
||||
shape = SubResource("CapsuleShape3D_hit")
|
||||
|
||||
[node name="bear_model" parent="." unique_id=359217823 instance=ExtResource("2_bearglb")]
|
||||
|
||||
[node name="Bear_FX" parent="bear_model" unique_id=2070553519 instance=ExtResource("3_bearfx")]
|
||||
|
||||
[node name="Bear_fx_claw_attack_R" parent="bear_model/Bear_FX" index="2" unique_id=1939248432]
|
||||
surface_material_override/0 = ExtResource("4_clawfx")
|
||||
|
||||
[node name="Bear_fx_claw_attack_L" parent="bear_model/Bear_FX" index="3" unique_id=834640978]
|
||||
surface_material_override/0 = ExtResource("4_clawfx")
|
||||
|
||||
[node name="AttackHitboxes" parent="bear_model" instance=ExtResource("5_hitboxes")]
|
||||
|
||||
[editable path="bear_model"]
|
||||
[editable path="bear_model/Bear_FX"]
|
||||
@@ -0,0 +1,70 @@
|
||||
[gd_scene format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://systems/combat/hitbox.gd" id="1_qxn4a"]
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_6dow8"]
|
||||
height = 3.0
|
||||
radius = 4.0
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_tmmfg"]
|
||||
size = Vector3(2.6, 2.5, 20)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_wcwtv"]
|
||||
length = 0.25
|
||||
tracks/0/type = "scale_3d"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("LeapSlamHitbox/CollisionShape3D")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = PackedFloat32Array(0, 1, 0.12, 1, 0.12, 0.06, 1, 1, 1, 1, 0.25, 1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_bg5u7"]
|
||||
length = 0.3
|
||||
tracks/0/type = "scale_3d"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("SmashHitbox/CollisionShape3D")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = PackedFloat32Array(0, 1, 1, 1, 0.02, 0.1, 1, 1, 1, 1, 0.3, 1, 1, 1, 1)
|
||||
tracks/1/type = "position_3d"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("SmashHitbox/CollisionShape3D")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = PackedFloat32Array(0, 1, 0, 0.9, 0.2, 0.1, 1, 0, 0.9, 10, 0.3, 1, 0, 0.9, 10)
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_u1id2"]
|
||||
_data = {
|
||||
&"leap_slam": SubResource("Animation_wcwtv"),
|
||||
&"smash_travel": SubResource("Animation_bg5u7")
|
||||
}
|
||||
|
||||
[node name="AttackHitboxes" type="Node3D" unique_id=2010404706]
|
||||
|
||||
[node name="LeapSlamHitbox" type="Area3D" parent="." unique_id=1751893032]
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
monitoring = false
|
||||
monitorable = false
|
||||
script = ExtResource("1_qxn4a")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="LeapSlamHitbox" unique_id=1320172052]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
|
||||
shape = SubResource("CylinderShape3D_6dow8")
|
||||
|
||||
[node name="SmashHitbox" type="Area3D" parent="." unique_id=1579648726]
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
monitoring = false
|
||||
monitorable = false
|
||||
script = ExtResource("1_qxn4a")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="SmashHitbox" unique_id=528637962]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, 10)
|
||||
shape = SubResource("BoxShape3D_tmmfg")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=2139876757]
|
||||
libraries/ = SubResource("AnimationLibrary_u1id2")
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
uid://bvfa7xi0luysk
|
||||
@@ -0,0 +1,28 @@
|
||||
[gd_scene format=3 uid="uid://d0te4mwbh33ag"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bvfa7xi0luysk" path="res://actors/matador/matador.gd" id="1_matgd"]
|
||||
[ext_resource type="PackedScene" uid="uid://eu2lqjhowj4t" path="res://Assets/Matador.glb" id="2_matfbx"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_body"]
|
||||
radius = 0.25
|
||||
height = 1.2
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_hit"]
|
||||
radius = 0.45
|
||||
height = 1.4
|
||||
|
||||
[node name="Matador" type="CharacterBody3D" unique_id=1781857630]
|
||||
script = ExtResource("1_matgd")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=2101651042]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.85, 0)
|
||||
shape = SubResource("CapsuleShape3D_body")
|
||||
|
||||
[node name="HitArea" type="Area3D" parent="." unique_id=745037545]
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="HitArea" unique_id=1497356275]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.85, 0)
|
||||
shape = SubResource("CapsuleShape3D_hit")
|
||||
|
||||
[node name="matador2" parent="." unique_id=1487256381 instance=ExtResource("2_matfbx")]
|
||||
@@ -0,0 +1,92 @@
|
||||
class_name MatadorRagdoll
|
||||
extends RefCounted
|
||||
## Builds the matador's physical-bone ragdoll. Body joints are cone-twist with
|
||||
## limited swing/twist (DP-tunable) so the corpse keeps its silhouette instead of
|
||||
## folding into a flat "deflated" pile; the cape stays free (PIN) so it drapes.
|
||||
|
||||
const PhysicsLayers = preload("res://systems/combat/physics_layers.gd")
|
||||
|
||||
# [bone, radius] → sphere collider; [bone, radius, height] → capsule.
|
||||
const _BONES: Array = [
|
||||
["matador", 0.18],
|
||||
["COG", 0.12],
|
||||
["chest", 0.13, 0.30],
|
||||
["head", 0.14],
|
||||
["collarbone_L", 0.06, 0.18],
|
||||
["collarbone_R", 0.06, 0.18],
|
||||
["arm_L", 0.07, 0.22],
|
||||
["arm_R", 0.07, 0.22],
|
||||
["forearm_L", 0.06, 0.22],
|
||||
["forearm_R", 0.06, 0.22],
|
||||
["hand_L", 0.05, 0.12],
|
||||
["hand_R", 0.05, 0.12],
|
||||
["leg_L", 0.10, 0.32],
|
||||
["leg_R", 0.10, 0.32],
|
||||
["shin_L", 0.08, 0.28],
|
||||
["shin_R", 0.08, 0.28],
|
||||
["foot_L", 0.07, 0.18],
|
||||
["foot_R", 0.07, 0.18],
|
||||
["Bone", 0.04, 0.30],
|
||||
["Bone.001", 0.04, 0.34],
|
||||
["Bone.002", 0.04, 0.30],
|
||||
]
|
||||
|
||||
|
||||
# Reuse an existing simulator if the rig already has one, else build the bodies.
|
||||
static func build(skeleton: Skeleton3D) -> PhysicalBoneSimulator3D:
|
||||
for child: Node in skeleton.get_children():
|
||||
if child is PhysicalBoneSimulator3D:
|
||||
(child as PhysicalBoneSimulator3D).active = false
|
||||
return child as PhysicalBoneSimulator3D
|
||||
|
||||
var sim := PhysicalBoneSimulator3D.new()
|
||||
sim.active = false
|
||||
skeleton.add_child(sim)
|
||||
|
||||
var swing := DP.f("mat_joint_swing")
|
||||
var twist := DP.f("mat_joint_twist")
|
||||
var damp := DP.f("mat_ragdoll_damp")
|
||||
|
||||
for entry: Array in _BONES:
|
||||
var bname: String = entry[0]
|
||||
if skeleton.find_bone(bname) == -1:
|
||||
continue
|
||||
var pb := PhysicalBone3D.new()
|
||||
pb.bone_name = bname
|
||||
pb.mass = 0.4
|
||||
pb.linear_damp = 0.1
|
||||
# The ragdoll only simulates once the matador is dead, so it lives on the CORPSE
|
||||
# layer and masks to CORPSE alone: it rests on the ground/walls (which also carry
|
||||
# CORPSE) but the bull — which collides only with WORLD — passes straight through
|
||||
# the bodies instead of tripping over them.
|
||||
pb.collision_layer = PhysicsLayers.CORPSE
|
||||
pb.collision_mask = PhysicsLayers.CORPSE
|
||||
if bname.begins_with("Bone"):
|
||||
# Cape: floppy cloth — free swing, light, draggy, one-way collision (layer 0
|
||||
# so nothing collides with it; it still drapes on the CORPSE-masked ground).
|
||||
pb.joint_type = PhysicalBone3D.JOINT_TYPE_PIN
|
||||
pb.mass = 0.15
|
||||
pb.linear_damp = 0.5
|
||||
pb.angular_damp = 0.7
|
||||
pb.collision_layer = 0
|
||||
else:
|
||||
# Body: cone-twist joints cap how far each bone bends from its rest
|
||||
# pose, so the silhouette holds; extra angular damp settles the flail.
|
||||
pb.joint_type = PhysicalBone3D.JOINT_TYPE_CONE
|
||||
pb.angular_damp = damp
|
||||
pb.set(&"joint_constraints/swing_span", swing)
|
||||
pb.set(&"joint_constraints/twist_span", twist)
|
||||
var cs := CollisionShape3D.new()
|
||||
if entry.size() >= 3:
|
||||
var cap := CapsuleShape3D.new()
|
||||
cap.radius = entry[1]
|
||||
cap.height = entry[2]
|
||||
cs.shape = cap
|
||||
else:
|
||||
var sph := SphereShape3D.new()
|
||||
sph.radius = entry[1]
|
||||
cs.shape = sph
|
||||
pb.add_child(cs)
|
||||
sim.add_child(pb)
|
||||
|
||||
return sim
|
||||
@@ -0,0 +1 @@
|
||||
uid://dmf04b5exnejn
|
||||
@@ -0,0 +1,15 @@
|
||||
[gd_scene format=3 uid="uid://c8spearwrap01"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://jepc74w8opbu" path="res://Assets/spear.glb" id="1_spearglb"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_shaft"]
|
||||
radius = 0.13
|
||||
height = 2.2
|
||||
|
||||
[node name="Spear" type="Node3D"]
|
||||
|
||||
[node name="spear" parent="." instance=ExtResource("1_spearglb")]
|
||||
|
||||
[node name="HitShape" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0.79)
|
||||
shape = SubResource("CapsuleShape3D_shaft")
|
||||
@@ -0,0 +1,253 @@
|
||||
class_name SpearProjectile
|
||||
extends RigidBody3D
|
||||
|
||||
# A thrown spear. It flies a ballistic arc (gravity does the work — the launch
|
||||
# velocity is solved by the matador to land on the bull) and keeps its shaft aimed
|
||||
# along its own velocity, so it noses over at the apex and drives in point-first.
|
||||
# On impact it embeds where it struck: the tip buried just past the contact point
|
||||
# with the shaft trailing back along the flight line, so it reads as stuck-in rather
|
||||
# than floating alongside. A hit on the bull leaves the spear riding it like a spine
|
||||
# (see shed_all, which the bull's slam calls to fling them all off); other hits pin
|
||||
# it in place until the despawn timer clears it.
|
||||
|
||||
const PhysicsLayers = preload("res://systems/combat/physics_layers.gd")
|
||||
|
||||
const _DESPAWN_SEC: float = 8.0
|
||||
const _STUCK_GROUP: StringName = &"stuck_spear"
|
||||
# Shaft geometry in spear.glb local space: tip at +Z, butt behind the origin.
|
||||
const _TIP_Z: float = 1.915
|
||||
const _EMBED_DEPTH: float = 0.72 # how far past the surface the tip buries
|
||||
# Bone the bull's spears ride on. The collision spheres sit outside the hide, so a
|
||||
# spear stuck to the body root reads as floating; anchoring to COG also lets it bob
|
||||
# and rotate with the animated body instead of only the character root.
|
||||
const _COG_BONE: String = "COG"
|
||||
const _ANCHOR_NAME: String = "SpearAnchor"
|
||||
|
||||
var _mesh: Node3D = null
|
||||
var _stopped: bool = false
|
||||
var _flight_dir: Vector3 = Vector3.ZERO # last pre-impact travel direction
|
||||
|
||||
|
||||
# Build, seat and launch a spear from an already-instantiated mesh (the one that was
|
||||
# in the matador's hand). `origin` is the release point; `velocity` is the full
|
||||
# ballistic launch vector; `gravity` is the RigidBody gravity_scale for the arc.
|
||||
static func launch(parent: Node, mesh: Node3D, origin: Vector3, velocity: Vector3,
|
||||
gravity: float) -> SpearProjectile:
|
||||
var s := SpearProjectile.new()
|
||||
s.gravity_scale = gravity
|
||||
s.collision_layer = 0
|
||||
# Mask WORLD so a miss sticks in the arena, and BULL so it can actually hit the
|
||||
# bull — the bull's body is on layer BULL, not WORLD, so a WORLD-only mask flew
|
||||
# straight through it (every throw whiffed, even against a stationary bull).
|
||||
s.collision_mask = PhysicsLayers.WORLD | PhysicsLayers.BULL
|
||||
s.contact_monitor = true
|
||||
s.max_contacts_reported = 6
|
||||
parent.add_child(s)
|
||||
# Seat the body so its local +Z (the shaft, see spear.glb) points along the throw.
|
||||
s.global_transform = Transform3D(_aim_basis(velocity), origin)
|
||||
# Take the editor-tweakable collider from the spear wrapper (Spear.tscn's HitShape)
|
||||
# before reparenting, then drop the now-nested template.
|
||||
var collider := _collider_from(mesh)
|
||||
mesh.reparent(s, false)
|
||||
mesh.transform = Transform3D.IDENTITY
|
||||
s._mesh = mesh
|
||||
var tmpl := mesh.get_node_or_null("HitShape")
|
||||
if tmpl != null:
|
||||
tmpl.queue_free()
|
||||
s.add_child(collider)
|
||||
s.linear_velocity = velocity
|
||||
_despawn(s)
|
||||
return s
|
||||
|
||||
|
||||
# Shed every spear stuck in `bull` — pop each off as a tumbling body that flies clear
|
||||
# and clears itself on the despawn timer. Called by the bull's slam.
|
||||
static func shed_all(bull: Node) -> void:
|
||||
if not (bull is Node3D):
|
||||
return
|
||||
var scene: Node = bull.get_tree().current_scene
|
||||
if scene == null:
|
||||
scene = bull
|
||||
var center: Vector3 = (bull as Node3D).global_position
|
||||
# Stuck spears now live under a BoneAttachment3D deep in the skeleton, so walk the
|
||||
# whole subtree by group rather than only the bull's direct children.
|
||||
for node in bull.get_tree().get_nodes_in_group(_STUCK_GROUP):
|
||||
if not (bull as Node).is_ancestor_of(node):
|
||||
continue
|
||||
var mesh := node as Node3D
|
||||
var gx := mesh.global_transform
|
||||
var rb := RigidBody3D.new()
|
||||
rb.collision_layer = 0
|
||||
rb.collision_mask = 1
|
||||
scene.add_child(rb)
|
||||
rb.global_transform = gx
|
||||
mesh.reparent(rb, false)
|
||||
mesh.transform = Transform3D.IDENTITY
|
||||
mesh.remove_from_group(_STUCK_GROUP)
|
||||
rb.add_child(_shaft_collider())
|
||||
# Fling outward from the bull with a bit of lift and spin.
|
||||
var out := gx.origin - center
|
||||
out.y = 0.0
|
||||
out = out.normalized() if out.length() > 0.01 else Vector3(randf() - 0.5, 0.0, randf() - 0.5)
|
||||
rb.linear_velocity = out * randf_range(3.0, 6.0) + Vector3.UP * randf_range(3.0, 5.0)
|
||||
rb.angular_velocity = Vector3(randf_range(-10.0, 10.0),
|
||||
randf_range(-10.0, 10.0), randf_range(-10.0, 10.0))
|
||||
_despawn(rb)
|
||||
|
||||
|
||||
# Clone the wrapper's editor-tweakable HitShape (Spear.tscn) into a fresh CollisionShape3D
|
||||
# for the projectile body; falls back to the built-in shaft collider if it's missing.
|
||||
static func _collider_from(source: Node) -> CollisionShape3D:
|
||||
var tmpl := source.get_node_or_null("HitShape") as CollisionShape3D
|
||||
if tmpl != null and tmpl.shape != null:
|
||||
var cs := CollisionShape3D.new()
|
||||
cs.shape = tmpl.shape
|
||||
cs.transform = tmpl.transform
|
||||
return cs
|
||||
return _shaft_collider()
|
||||
|
||||
|
||||
static func _shaft_collider() -> CollisionShape3D:
|
||||
# Collider along local +Z (mesh runs z≈-0.34 … 1.92), fattened so a fast throw
|
||||
# can't tunnel past the bull's collision spheres.
|
||||
var cap := CapsuleShape3D.new()
|
||||
cap.radius = 0.13
|
||||
cap.height = 2.2
|
||||
var cs := CollisionShape3D.new()
|
||||
cs.shape = cap
|
||||
cs.position = Vector3(0.0, 0.0, 0.79)
|
||||
cs.rotation_degrees = Vector3(90.0, 0.0, 0.0)
|
||||
return cs
|
||||
|
||||
|
||||
# Continuous bleed from a spear lodged in the bull: a steady spurt of dark-red gobs out
|
||||
# of the entry wound. Parented to the stuck mesh so it tracks the wound as the bull
|
||||
# moves; world-space particles (local_coords off) so they arc off and fall behind as a
|
||||
# trail. Dies with the mesh when the spear is shed or despawned.
|
||||
static func _wound_emitter() -> CPUParticles3D:
|
||||
var ramp := Gradient.new()
|
||||
ramp.set_color(0, Color(0.5, 0.02, 0.02, 1.0))
|
||||
ramp.set_color(1, Color(0.22, 0.0, 0.0, 0.0))
|
||||
|
||||
var sc := Curve.new()
|
||||
sc.add_point(Vector2(0.0, 1.0))
|
||||
sc.add_point(Vector2(0.6, 0.7))
|
||||
sc.add_point(Vector2(1.0, 0.0))
|
||||
|
||||
var p := CPUParticles3D.new()
|
||||
# Seat at the wound (where the shaft meets the hide) and spray back out along the
|
||||
# shaft: mesh local -Z is the exit direction, rotated into world by the node basis.
|
||||
p.position = Vector3(0.0, 0.0, _TIP_Z - _EMBED_DEPTH)
|
||||
p.emitting = true
|
||||
p.amount = 22
|
||||
p.lifetime = 0.6
|
||||
p.explosiveness = 0.0
|
||||
p.randomness = 0.6
|
||||
p.local_coords = false
|
||||
p.direction = Vector3(0.0, 0.55, -1.0).normalized()
|
||||
p.spread = 32.0
|
||||
p.gravity = Vector3(0.0, -12.0, 0.0)
|
||||
p.initial_velocity_min = 1.6
|
||||
p.initial_velocity_max = 4.0
|
||||
p.scale_amount_min = 0.5
|
||||
p.scale_amount_max = 1.4
|
||||
p.mesh = _blood_mesh()
|
||||
p.color_ramp = ramp
|
||||
p.scale_amount_curve = sc
|
||||
return p
|
||||
|
||||
|
||||
# Small unshaded, vertex-coloured sphere for blood gobs.
|
||||
static func _blood_mesh() -> SphereMesh:
|
||||
var mat := StandardMaterial3D.new()
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
mat.vertex_color_use_as_albedo = true
|
||||
mat.cull_mode = BaseMaterial3D.CULL_DISABLED
|
||||
var s := SphereMesh.new()
|
||||
s.radius = 0.045
|
||||
s.height = 0.09
|
||||
s.radial_segments = 4
|
||||
s.rings = 2
|
||||
s.material = mat
|
||||
return s
|
||||
|
||||
|
||||
static func _despawn(node: Node) -> void:
|
||||
node.get_tree().create_timer(_DESPAWN_SEC).timeout.connect(func() -> void:
|
||||
if is_instance_valid(node):
|
||||
node.queue_free()
|
||||
)
|
||||
|
||||
|
||||
# Basis whose local +Z points along `v` (looking_at points -Z at its target).
|
||||
static func _aim_basis(v: Vector3) -> Basis:
|
||||
var dir := v.normalized()
|
||||
if dir.length_squared() < 0.0001:
|
||||
return Basis.IDENTITY
|
||||
var up := Vector3.UP if absf(dir.dot(Vector3.UP)) < 0.99 else Vector3.FORWARD
|
||||
return Basis.looking_at(-dir, up)
|
||||
|
||||
|
||||
# While flying, keep the shaft aligned with the velocity; on the first contact freeze
|
||||
# and hand off to _embed so the spear sticks where it struck instead of bouncing off.
|
||||
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
||||
if _stopped:
|
||||
return
|
||||
if state.get_contact_count() > 0:
|
||||
_stopped = true
|
||||
# Use the remembered pre-impact heading — state.linear_velocity is already the
|
||||
# bounced (post-collision) velocity by now, which would aim the shaft wrong.
|
||||
var contact := state.get_contact_collider_position(0)
|
||||
var other := state.get_contact_collider_object(0)
|
||||
state.linear_velocity = Vector3.ZERO
|
||||
state.angular_velocity = Vector3.ZERO
|
||||
_embed.call_deferred(other, contact, _flight_dir)
|
||||
return
|
||||
var v := state.linear_velocity
|
||||
if v.length_squared() > 0.04:
|
||||
_flight_dir = v.normalized()
|
||||
var t := state.transform
|
||||
t.basis = _aim_basis(v)
|
||||
state.transform = t
|
||||
state.angular_velocity = Vector3.ZERO
|
||||
|
||||
|
||||
# Compose the stuck pose (tip buried _EMBED_DEPTH past the contact, shaft along the
|
||||
# flight line) and plant the spear. A bull hit hands the mesh to the bull so it rides
|
||||
# along as a spine; anything else pins the body in place for the despawn timer.
|
||||
func _embed(other: Object, contact: Vector3, flight: Vector3) -> void:
|
||||
var f := flight.normalized()
|
||||
if f.length_squared() < 0.0001:
|
||||
f = global_transform.basis.z.normalized()
|
||||
var pose := Transform3D(_aim_basis(f), contact + f * (_EMBED_DEPTH - _TIP_Z))
|
||||
var bull := other as Node
|
||||
if bull != null and bull.is_in_group(&"player"):
|
||||
DamageEvent.deal(bull, DamageEvent.Cause.THROWN, contact, self)
|
||||
if is_instance_valid(_mesh) and is_instance_valid(bull):
|
||||
_mesh.reparent(_spear_anchor(bull), false)
|
||||
_mesh.global_transform = pose
|
||||
_mesh.add_to_group(_STUCK_GROUP)
|
||||
if Settings.gore:
|
||||
_mesh.add_child(_wound_emitter()) # keep bleeding from the wound while lodged
|
||||
queue_free()
|
||||
return
|
||||
freeze = true
|
||||
global_transform = pose
|
||||
|
||||
|
||||
# Node embedded spears ride on the bull: a BoneAttachment3D pinned to the COG bone so
|
||||
# they follow the animated body (bob, turn) rather than only the character root. One
|
||||
# anchor is shared by every spear; falls back to the bull root if there's no skeleton.
|
||||
static func _spear_anchor(bull: Node) -> Node3D:
|
||||
var existing := bull.find_child(_ANCHOR_NAME, true, false)
|
||||
if existing is Node3D:
|
||||
return existing as Node3D
|
||||
var skel := bull.find_child("Skeleton3D", true, false) as Skeleton3D
|
||||
if skel == null:
|
||||
return bull as Node3D
|
||||
var ba := BoneAttachment3D.new()
|
||||
ba.name = _ANCHOR_NAME
|
||||
skel.add_child(ba)
|
||||
ba.bone_name = _COG_BONE
|
||||
return ba
|
||||
@@ -0,0 +1 @@
|
||||
uid://dwjakh1is1jtj
|
||||
@@ -0,0 +1,20 @@
|
||||
[gd_scene format=3 uid="uid://c8swordwrap01"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://xyvank512l5n" path="res://Assets/sword.glb" id="1_swordglb"]
|
||||
[ext_resource type="Script" path="res://systems/combat/hitbox.gd" id="2_hitbox"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_blade"]
|
||||
radius = 0.18
|
||||
height = 1.3
|
||||
|
||||
[node name="Sword" type="Node3D"]
|
||||
|
||||
[node name="sword" parent="." instance=ExtResource("1_swordglb")]
|
||||
|
||||
[node name="BladeHitbox" type="Area3D" parent="."]
|
||||
script = ExtResource("2_hitbox")
|
||||
damage_cause = "gored"
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="BladeHitbox"]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0.8)
|
||||
shape = SubResource("CapsuleShape3D_blade")
|
||||
@@ -0,0 +1,295 @@
|
||||
extends Node
|
||||
## Body wobble and tail simulation. Legs stay in rest pose (no IK, no ragdoll).
|
||||
## Created at runtime by player.gd; call setup() before the first _process tick.
|
||||
|
||||
var _player: CharacterBody3D
|
||||
var _bull: Node3D
|
||||
var _skeleton: Skeleton3D
|
||||
|
||||
# Body wobble
|
||||
var _prev_vel: Vector3 = Vector3.ZERO
|
||||
var _tilt_x: float = 0.0
|
||||
var _tilt_z: float = 0.0
|
||||
var _aerial_pitch: float = 0.0
|
||||
|
||||
var charge_pitch_target: float = 0.0
|
||||
var _charge_pitch_curr: float = 0.0
|
||||
|
||||
# When true, another system (the roll's ball-tumble) owns the bull's full
|
||||
# orientation — skip writing body wobble so we don't fight it.
|
||||
var external_rotation: bool = false
|
||||
|
||||
# Tail — Verlet chain simulation
|
||||
const TAIL_BONES: Array = [
|
||||
&"tail_1", &"tail_2", &"tail_3", &"tail_4",
|
||||
&"tail_5", &"tail_6",
|
||||
&"tail_tip_1", &"tail_tip_2", &"tail_tip_2_end",
|
||||
]
|
||||
var _tail_idx: Array[int] = []
|
||||
var _tail_world: Array[Vector3] = []
|
||||
var _tail_prev: Array[Vector3] = []
|
||||
var _tail_lengths: Array[float] = []
|
||||
var _tail_rest_dir: Array[Vector3] = []
|
||||
var _tail_parent_idx: int = -1
|
||||
|
||||
var tail_ragdoll: bool = false
|
||||
var _prev_on_floor: bool = true
|
||||
|
||||
var _dbg_on: bool = false
|
||||
var _dbg_nodes: Array[MeshInstance3D] = []
|
||||
|
||||
|
||||
func setup(player: CharacterBody3D, bull: Node3D) -> void:
|
||||
_player = player
|
||||
_bull = bull
|
||||
_skeleton = _find_skeleton(bull)
|
||||
if not _skeleton:
|
||||
push_error("BullLegs: Skeleton3D not found under bull")
|
||||
return
|
||||
|
||||
# Disable any physical bone simulator
|
||||
var phys_sim := _find_physical_bones(_skeleton)
|
||||
if phys_sim:
|
||||
phys_sim.active = false
|
||||
|
||||
_setup_tail()
|
||||
|
||||
|
||||
func _setup_tail() -> void:
|
||||
for bone_name: StringName in TAIL_BONES:
|
||||
var idx: int = _skeleton.find_bone(bone_name)
|
||||
if idx == -1:
|
||||
push_warning("BullLegs: tail bone '%s' not found" % bone_name)
|
||||
continue
|
||||
_tail_idx.append(idx)
|
||||
|
||||
if _tail_idx.size() < 2:
|
||||
push_error("BullLegs: not enough tail bones found")
|
||||
return
|
||||
|
||||
for idx: int in _tail_idx:
|
||||
var world: Vector3 = _skeleton.to_global(_skeleton.get_bone_global_rest(idx).origin)
|
||||
_tail_world.append(world)
|
||||
_tail_prev.append(world)
|
||||
|
||||
var max_sep: float = 0.0
|
||||
for i in range(_tail_world.size() - 1):
|
||||
max_sep = maxf(max_sep, _tail_world[i].distance_to(_tail_world[i + 1]))
|
||||
if max_sep < 0.01:
|
||||
push_warning("BullLegs: tail bones have zero separation in rest pose, distributing along spine")
|
||||
var root: Vector3 = _tail_world[0]
|
||||
var back: Vector3 = (_skeleton.global_transform.basis.z + Vector3.DOWN * 0.3).normalized()
|
||||
for i in range(_tail_world.size()):
|
||||
_tail_world[i] = root + back * (i * 0.09)
|
||||
_tail_prev[i] = _tail_world[i]
|
||||
|
||||
const MIN_SEG: float = 0.06
|
||||
for i in range(_tail_world.size() - 1):
|
||||
var seg_len: float = _tail_world[i].distance_to(_tail_world[i + 1])
|
||||
_tail_lengths.append(maxf(seg_len, MIN_SEG))
|
||||
|
||||
for i in range(_tail_world.size() - 1):
|
||||
var p1_skel: Vector3 = _skeleton.to_local(_tail_world[i])
|
||||
var p2_skel: Vector3 = _skeleton.to_local(_tail_world[i + 1])
|
||||
var seg_skel: Vector3 = p2_skel - p1_skel
|
||||
_tail_rest_dir.append(seg_skel.normalized() if seg_skel.length() > 0.001 else Vector3(0, 0, 1))
|
||||
_tail_rest_dir.append(_tail_rest_dir[-1])
|
||||
|
||||
_tail_parent_idx = _skeleton.get_bone_parent(_tail_idx[0])
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not _skeleton:
|
||||
return
|
||||
_wobble_body(delta)
|
||||
_update_tail(delta)
|
||||
_apply_tail()
|
||||
if DP.b("show_tail") != _dbg_on:
|
||||
_dbg_toggle()
|
||||
if _dbg_on:
|
||||
_dbg_update()
|
||||
|
||||
|
||||
# ── Body Wobble ───────────────────────────────────────────────────────────────
|
||||
|
||||
func _wobble_body(delta: float) -> void:
|
||||
var vel: Vector3 = _player.velocity
|
||||
var accel: Vector3 = (vel - _prev_vel) / maxf(delta, 0.001)
|
||||
_prev_vel = vel
|
||||
|
||||
var la: Vector3 = _bull.global_transform.basis.inverse() * accel
|
||||
|
||||
var tx := clampf(-la.z * DP.f("body_tilt_fwd"), -0.35, 0.35)
|
||||
var tz := clampf(-la.x * DP.f("body_tilt_side"), -0.25, 0.25)
|
||||
|
||||
_tilt_x = lerpf(_tilt_x, tx, delta * 10.0)
|
||||
_tilt_z = lerpf(_tilt_z, tz, delta * 10.0)
|
||||
|
||||
var flat_spd: float = Vector2(vel.x, vel.z).length()
|
||||
var target_pitch: float = 0.0
|
||||
if not _player.is_on_floor() and flat_spd > 0.5:
|
||||
target_pitch = clampf(-atan2(vel.y, flat_spd) * DP.f("aerial_pitch_scale"), -1.4, 1.4)
|
||||
_aerial_pitch = lerpf(_aerial_pitch, target_pitch, delta * DP.f("aerial_pitch_speed"))
|
||||
|
||||
_charge_pitch_curr = lerpf(_charge_pitch_curr, charge_pitch_target, delta * DP.f("charge_head_speed"))
|
||||
if external_rotation:
|
||||
return
|
||||
_bull.rotation.x = _tilt_x + _aerial_pitch + _charge_pitch_curr
|
||||
_bull.rotation.z = _tilt_z
|
||||
|
||||
|
||||
# ── Tail ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
func _update_tail(delta: float) -> void:
|
||||
if _tail_world.is_empty():
|
||||
return
|
||||
|
||||
var gravity := Vector3(0.0, -DP.f("tail_gravity"), 0.0)
|
||||
var damping := 1.0 - clampf(DP.f("tail_damping"), 0.0, 0.99)
|
||||
|
||||
var anchor: Vector3
|
||||
if _tail_parent_idx >= 0:
|
||||
var parent_t := _skeleton.get_bone_global_pose(_tail_parent_idx)
|
||||
anchor = _skeleton.to_global((parent_t * _skeleton.get_bone_rest(_tail_idx[0])).origin)
|
||||
else:
|
||||
anchor = _skeleton.to_global(_skeleton.get_bone_global_rest(_tail_idx[0]).origin)
|
||||
_tail_world[0] = anchor
|
||||
_tail_prev[0] = anchor
|
||||
|
||||
var on_floor := _player.is_on_floor()
|
||||
if not on_floor and _prev_on_floor:
|
||||
# Bull just left the ground — push all tail particles upward with it
|
||||
for i: int in range(1, _tail_world.size()):
|
||||
_tail_prev[i] = _tail_world[i] - _player.velocity * delta
|
||||
_prev_on_floor = on_floor
|
||||
|
||||
var gravity_mult: float
|
||||
if tail_ragdoll:
|
||||
gravity_mult = 2.5
|
||||
elif not on_floor:
|
||||
gravity_mult = 0.15
|
||||
else:
|
||||
gravity_mult = 1.0
|
||||
gravity *= gravity_mult
|
||||
|
||||
var flat_speed: float = Vector2(_player.velocity.x, _player.velocity.z).length()
|
||||
var wag_strength: float = lerpf(DP.f("tail_wag_idle"), 0.0, clampf(flat_speed / 3.0, 0.0, 1.0))
|
||||
var wag_freq: float = DP.f("tail_wag_freq")
|
||||
var time: float = Time.get_ticks_msec() / 1000.0
|
||||
var basis_x: Vector3 = _bull.global_transform.basis.x
|
||||
|
||||
for i in range(1, _tail_world.size()):
|
||||
var vel: Vector3 = (_tail_world[i] - _tail_prev[i]) * damping
|
||||
_tail_prev[i] = _tail_world[i]
|
||||
var wag := Vector3.ZERO if tail_ragdoll \
|
||||
else basis_x * sin(time * wag_freq + i * 0.5) * wag_strength
|
||||
_tail_world[i] = _tail_world[i] + vel + gravity * (delta * delta) + wag * delta
|
||||
|
||||
for i in range(1, _tail_world.size()):
|
||||
var dir: Vector3 = _tail_world[i] - _tail_world[i - 1]
|
||||
var len: float = dir.length()
|
||||
var target_len: float = _tail_lengths[i - 1]
|
||||
if len > 0.0001:
|
||||
_tail_world[i] = _tail_world[i - 1] + dir * (target_len / len)
|
||||
else:
|
||||
_tail_world[i] = _tail_world[i - 1] + Vector3(0.0, -target_len, 0.0)
|
||||
|
||||
var body_radius: float = DP.f("tail_body_radius")
|
||||
for i in range(1, _tail_world.size()):
|
||||
var p := _bull.to_local(_tail_world[i])
|
||||
var closest := Vector3(0.0, 0.0, clampf(p.z, -0.3, 0.5))
|
||||
var diff := p - closest
|
||||
var dist := diff.length()
|
||||
if dist < body_radius and dist > 0.001:
|
||||
p = closest + diff.normalized() * body_radius
|
||||
_tail_world[i] = _bull.to_global(p)
|
||||
|
||||
|
||||
func _apply_tail() -> void:
|
||||
if _tail_world.is_empty():
|
||||
return
|
||||
|
||||
var n := _tail_world.size()
|
||||
var local_pos: Array[Vector3] = []
|
||||
local_pos.resize(n)
|
||||
for i in n:
|
||||
local_pos[i] = _skeleton.to_local(_tail_world[i])
|
||||
|
||||
for i in n:
|
||||
var idx: int = _tail_idx[i]
|
||||
var pos_skel: Vector3 = local_pos[i]
|
||||
|
||||
var point_dir_skel: Vector3
|
||||
if i < n - 1:
|
||||
point_dir_skel = (local_pos[i + 1] - pos_skel).normalized()
|
||||
else:
|
||||
point_dir_skel = (pos_skel - local_pos[i - 1]).normalized()
|
||||
|
||||
var rest_dir: Vector3 = _tail_rest_dir[i]
|
||||
var rest_t: Transform3D = _skeleton.get_bone_global_rest(idx)
|
||||
var new_basis: Basis
|
||||
if rest_dir.length_squared() > 0.0001 and point_dir_skel.length_squared() > 0.0001:
|
||||
new_basis = Basis(Quaternion(rest_dir, point_dir_skel)) * rest_t.basis
|
||||
else:
|
||||
new_basis = rest_t.basis
|
||||
|
||||
_skeleton.set_bone_global_pose_override(idx, Transform3D(new_basis, pos_skel), 1.0, false)
|
||||
|
||||
|
||||
# ── Debug Visualization ───────────────────────────────────────────────────────
|
||||
|
||||
func _dbg_toggle() -> void:
|
||||
if _dbg_on:
|
||||
for n: MeshInstance3D in _dbg_nodes:
|
||||
if is_instance_valid(n):
|
||||
n.queue_free()
|
||||
_dbg_nodes.clear()
|
||||
_dbg_on = false
|
||||
else:
|
||||
_dbg_build()
|
||||
_dbg_on = true
|
||||
|
||||
|
||||
func _dbg_build() -> void:
|
||||
var root: Node = _player.get_parent()
|
||||
var n: int = _tail_world.size()
|
||||
for i: int in n:
|
||||
var mat := StandardMaterial3D.new()
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.render_priority = 1
|
||||
mat.albedo_color = Color.RED if i == 0 \
|
||||
else Color(1.0 - float(i) / n, 0.4 + 0.6 * float(i) / n, 0.0)
|
||||
var sm := SphereMesh.new()
|
||||
sm.radius = 0.10 if i == 0 else 0.06
|
||||
sm.height = sm.radius * 2.0
|
||||
sm.radial_segments = 6
|
||||
sm.rings = 3
|
||||
sm.material = mat
|
||||
var mi := MeshInstance3D.new()
|
||||
mi.mesh = sm
|
||||
root.add_child(mi)
|
||||
_dbg_nodes.append(mi)
|
||||
|
||||
|
||||
func _dbg_update() -> void:
|
||||
for i: int in _dbg_nodes.size():
|
||||
_dbg_nodes[i].global_position = _tail_world[i]
|
||||
|
||||
|
||||
# ── Utility ───────────────────────────────────────────────────────────────────
|
||||
|
||||
func _find_skeleton(node: Node) -> Skeleton3D:
|
||||
if node is Skeleton3D:
|
||||
return node as Skeleton3D
|
||||
for child in node.get_children():
|
||||
var r := _find_skeleton(child)
|
||||
if r:
|
||||
return r
|
||||
return null
|
||||
|
||||
|
||||
func _find_physical_bones(node: Node) -> PhysicalBoneSimulator3D:
|
||||
for child in node.get_children():
|
||||
if child is PhysicalBoneSimulator3D:
|
||||
return child as PhysicalBoneSimulator3D
|
||||
return null
|
||||
@@ -0,0 +1 @@
|
||||
uid://bvtw8s41wrrx
|
||||
@@ -0,0 +1,140 @@
|
||||
class_name IsoCamera
|
||||
extends Camera3D
|
||||
|
||||
@export var height: float = 25.0
|
||||
@export var horizontal_distance: float = 25.0
|
||||
@export var horizontal_angle_deg: float = 45.0
|
||||
|
||||
# Perspective zoom (FOV)
|
||||
@export var fov_min: float = 20.0
|
||||
@export var fov_max: float = 75.0
|
||||
@export var default_fov: float = 30.0
|
||||
|
||||
@export var focus_slice_thickness: float = 6.0
|
||||
@export var blur_transition: float = 15.0
|
||||
|
||||
var _shake_amount: float = 0.0
|
||||
var _shake_decay: float = 0.0
|
||||
var _user_fov: float = 0.0
|
||||
|
||||
# Per-level framing multiplier: 1.0 = the designer's base shot, >1 dollies the camera
|
||||
# back for a wider view (the lobby uses this). Set by game_shell when a level loads;
|
||||
# kept separate from the scroll-wheel FOV zoom so the two don't fight.
|
||||
var _framing_scale: float = 1.0
|
||||
|
||||
# Trailing-camera state: _focus is the smoothed point the camera frames (it lags
|
||||
# the bull), _drag_offset is the velocity-driven trail that slides it behind.
|
||||
var _focus: Vector3 = Vector3.ZERO
|
||||
var _drag_offset: Vector3 = Vector3.ZERO
|
||||
var _focus_init: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_as_top_level(true)
|
||||
|
||||
projection = Camera3D.PROJECTION_PERSPECTIVE
|
||||
fov = default_fov
|
||||
_user_fov = default_fov
|
||||
|
||||
near = 0.1
|
||||
far = 150.0
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("zoom_in"):
|
||||
_user_fov = clamp(_user_fov / 1.1, fov_min, fov_max)
|
||||
|
||||
if event.is_action_pressed("zoom_out"):
|
||||
_user_fov = clamp(_user_fov * 1.1, fov_min, fov_max)
|
||||
|
||||
|
||||
# Pinch-to-zoom hook for the touch UI. `ratio` is the two-finger spread this frame over
|
||||
# last frame: >1 (fingers parting) narrows the FOV to zoom in, <1 widens it to pull back,
|
||||
# mirroring the scroll-wheel zoom_in/zoom_out feel.
|
||||
func adjust_zoom(ratio: float) -> void:
|
||||
if ratio <= 0.0:
|
||||
return
|
||||
_user_fov = clampf(_user_fov / ratio, fov_min, fov_max)
|
||||
|
||||
|
||||
## Dolly the camera in/out for the level being loaded. 1.0 is the base framing; >1 pulls
|
||||
## back for a wider shot (the lobby hub uses this). Independent of the scroll-wheel zoom.
|
||||
func set_framing_scale(scale: float) -> void:
|
||||
_framing_scale = maxf(scale, 0.1)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
fov = lerpf(fov, _user_fov, delta * 8.0)
|
||||
|
||||
var angle_rad := deg_to_rad(horizontal_angle_deg)
|
||||
|
||||
var offset := Vector3(
|
||||
sin(angle_rad) * horizontal_distance * _framing_scale,
|
||||
height * _framing_scale,
|
||||
cos(angle_rad) * horizontal_distance * _framing_scale
|
||||
)
|
||||
|
||||
var target := get_parent() as Node3D
|
||||
var focus := _drag_focus(target, delta)
|
||||
|
||||
global_position = focus + offset
|
||||
look_at(focus, Vector3.UP)
|
||||
|
||||
_update_dof(focus)
|
||||
|
||||
if _shake_amount > 0.005:
|
||||
global_position += Vector3(
|
||||
randf_range(-_shake_amount, _shake_amount),
|
||||
randf_range(-_shake_amount * 0.25, _shake_amount * 0.25),
|
||||
randf_range(-_shake_amount, _shake_amount)
|
||||
)
|
||||
|
||||
_shake_amount = move_toward(_shake_amount, 0.0, _shake_decay * delta)
|
||||
|
||||
|
||||
# Smoothed follow point that drags behind the bull. The target trail sits opposite
|
||||
# the bull's flat velocity (cam_drag metres per m/s); the offset and the focus both
|
||||
# ease toward their targets so the camera lags and settles rather than snapping.
|
||||
func _drag_focus(target: Node3D, delta: float) -> Vector3:
|
||||
var pos := target.global_position
|
||||
if not _focus_init:
|
||||
_focus = pos
|
||||
_focus_init = true
|
||||
|
||||
var vel := Vector3.ZERO
|
||||
if target is CharacterBody3D:
|
||||
vel = (target as CharacterBody3D).velocity
|
||||
vel.y = 0.0
|
||||
|
||||
var drag_target := -vel * DP.f("cam_drag")
|
||||
_drag_offset = _drag_offset.lerp(drag_target, clampf(DP.f("cam_drag_speed") * delta, 0.0, 1.0))
|
||||
_focus = _focus.lerp(pos + _drag_offset, clampf(DP.f("cam_follow_lerp") * delta, 0.0, 1.0))
|
||||
return _focus
|
||||
|
||||
|
||||
func trigger_hit(strength: float) -> void:
|
||||
if not Settings.screen_shake:
|
||||
return
|
||||
_shake_amount = strength * 0.5
|
||||
_shake_decay = _shake_amount / 0.4
|
||||
|
||||
|
||||
func _update_dof(target_pos: Vector3) -> void:
|
||||
var cam_attr: CameraAttributesPractical = null
|
||||
|
||||
if attributes is CameraAttributesPractical:
|
||||
cam_attr = attributes
|
||||
|
||||
if cam_attr == null:
|
||||
return
|
||||
|
||||
var distance := global_position.distance_to(target_pos)
|
||||
|
||||
cam_attr.dof_blur_near_distance = max(distance - focus_slice_thickness * 0.5, near + 0.1)
|
||||
cam_attr.dof_blur_far_distance = distance + focus_slice_thickness * 0.5
|
||||
|
||||
cam_attr.dof_blur_near_transition = blur_transition
|
||||
cam_attr.dof_blur_far_transition = blur_transition
|
||||
|
||||
cam_attr.dof_blur_near_enabled = false
|
||||
cam_attr.dof_blur_far_enabled = false
|
||||
@@ -0,0 +1 @@
|
||||
uid://cpyq2r5cq653g
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
uid://bn777gguclud5
|
||||
@@ -0,0 +1,52 @@
|
||||
[gd_scene format=3 uid="uid://crtm0xtiql3r8"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bn777gguclud5" path="res://actors/player/player.gd" id="1_xhfnw"]
|
||||
[ext_resource type="Script" uid="uid://cpyq2r5cq653g" path="res://actors/player/camera_iso.gd" id="2_camera_iso"]
|
||||
[ext_resource type="PackedScene" uid="uid://bun14xmk20pcj" path="res://Assets/bull.fbx" id="4_e80uo"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_kne1u"]
|
||||
radius = 0.7495117
|
||||
height = 1.845398
|
||||
|
||||
[node name="Player" type="CharacterBody3D" unique_id=165510044]
|
||||
collision_layer = 2
|
||||
collision_mask = 9
|
||||
script = ExtResource("1_xhfnw")
|
||||
|
||||
[node name="CollisionBull" type="CollisionShape3D" parent="." unique_id=571780801]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.29183745, 0.3197594)
|
||||
shape = SubResource("CapsuleShape3D_kne1u")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="." unique_id=1120161087]
|
||||
script = ExtResource("2_camera_iso")
|
||||
|
||||
[node name="bull" parent="." unique_id=1386495166 instance=ExtResource("4_e80uo")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.655, 0.23)
|
||||
|
||||
[node name="Skeleton3D" parent="bull/Armature" parent_id_path=PackedInt32Array(1386495166, 1942410469) index="0" unique_id=550138996]
|
||||
bones/0/position = Vector3(0, 0, 0.009963839)
|
||||
bones/0/rotation = Quaternion(0.7071068, 0, 0, 0.7071067)
|
||||
bones/0/scale = Vector3(1, 1, 1)
|
||||
bones/1/position = Vector3(0.003526625, -0.0043296535, 0.0040827994)
|
||||
bones/1/rotation = Quaternion(-0.00038647873, 0.06909673, 0.9868542, -0.14609687)
|
||||
bones/2/rotation = Quaternion(-0.06929122, 3.2175163e-07, -0.112670615, 0.99121344)
|
||||
bones/4/position = Vector3(0.0045358227, -0.002137695, -0.004238624)
|
||||
bones/4/rotation = Quaternion(-0.24948503, 0.19590352, 0.9416978, -0.11217985)
|
||||
bones/4/scale = Vector3(1.0000001, 0.9999999, 1.0000001)
|
||||
bones/5/rotation = Quaternion(-0.58943665, -0.3660725, -0.22564478, 0.683842)
|
||||
bones/5/scale = Vector3(1, 1.0000001, 0.99999994)
|
||||
bones/6/rotation = Quaternion(0.52910197, 0.15997827, 0.120245, 0.8246207)
|
||||
bones/6/scale = Vector3(1, 1, 1.0000001)
|
||||
bones/17/position = Vector3(0, 0.0009373814, 0.007552617)
|
||||
bones/17/rotation = Quaternion(-9.4156974e-08, 0.7071068, 0.7071067, -9.4156974e-08)
|
||||
bones/19/position = Vector3(-0.003526625, -0.0043296535, 0.0040827994)
|
||||
bones/19/rotation = Quaternion(0.00038647873, 0.06909673, 0.9868542, 0.14609687)
|
||||
bones/20/rotation = Quaternion(-0.06929122, -3.2227587e-07, 0.11267061, 0.99121344)
|
||||
bones/22/position = Vector3(-0.0045358227, -0.002137695, -0.004238624)
|
||||
bones/22/rotation = Quaternion(0.24948503, 0.19590352, 0.9416978, 0.11217985)
|
||||
bones/23/rotation = Quaternion(-0.58943665, 0.3660725, 0.22564478, 0.683842)
|
||||
bones/23/scale = Vector3(1, 1.0000001, 1)
|
||||
bones/24/rotation = Quaternion(0.529102, -0.15997836, -0.120245025, 0.82462066)
|
||||
bones/24/scale = Vector3(1, 1.0000001, 1)
|
||||
|
||||
[editable path="bull"]
|
||||
Reference in New Issue
Block a user