yaelatletl / godot-jigglebones

An addon that brings jigglebones to Godot Engine 4.0.
MIT License
115 stars 4 forks source link

Collisions not registering properly #13

Closed Luskarian closed 2 months ago

Luskarian commented 2 months ago

The collision script uses the position of the jigglebones, not the actual bones themselves Added a fix ` ############### Solve distance constraint ##############

var goal_pos: Vector3 = skeleton.to_global(skeleton.get_bone_global_pose(bone_id).origin)

if collision_sphere:
    # If bone is inside the collision sphere, push it out
    var test_vec: Vector3 = goal_pos - collision_sphere.global_transform.origin
    var distance: float = test_vec.length() - collision_sphere.shape.radius
    if distance < 0:
        goal_pos -= test_vec.normalized() * distance

global_transform.origin = goal_pos + (global_transform.origin - goal_pos).normalized()

`