Bear, level selector (to be removed), new matador spawn, new bear level, saving config updates source files
This commit is contained in:
+29
-5
@@ -14,7 +14,12 @@ 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.45 # how far past the surface the tip buries
|
||||
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
|
||||
@@ -53,10 +58,12 @@ static func shed_all(bull: Node) -> void:
|
||||
if scene == null:
|
||||
scene = bull
|
||||
var center: Vector3 = (bull as Node3D).global_position
|
||||
for child in bull.get_children():
|
||||
if not child.is_in_group(_STUCK_GROUP):
|
||||
# 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 := child as Node3D
|
||||
var mesh := node as Node3D
|
||||
var gx := mesh.global_transform
|
||||
var rb := RigidBody3D.new()
|
||||
rb.collision_layer = 0
|
||||
@@ -195,7 +202,7 @@ func _embed(other: Object, contact: Vector3, flight: Vector3) -> void:
|
||||
if bull != null and bull.is_in_group(&"player"):
|
||||
bull.call(&"take_sword_hit", "thrown", contact)
|
||||
if is_instance_valid(_mesh) and is_instance_valid(bull):
|
||||
_mesh.reparent(bull, false)
|
||||
_mesh.reparent(_spear_anchor(bull), false)
|
||||
_mesh.global_transform = pose
|
||||
_mesh.add_to_group(_STUCK_GROUP)
|
||||
if Settings.gore:
|
||||
@@ -204,3 +211,20 @@ func _embed(other: Object, contact: Vector3, flight: Vector3) -> void:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user