0 votes

So right now, I'm trying to set something up where when the character (KinematicBody2D, CollisionShape2D as child) collides with another KB2D/CS2D, the non-character collision object (the box) physically sticks to the character, like so: https://i.imgur.com/7Bu9Rv6.mp4

But as you can see, at certain approach angles, the box goes to the flip side of the character (and even has the correct spacing).

Along with this, the collisions aren't always perfect either https://i.imgur.com/wEztHEq.mp4

Sorry that my video isn't great, but there's a bit of a gap between the two boxes, when I want it to be flush. There'll also be times when the box will be further into the character (like a negative gap, the phrase escapes me right now), which I can't understand.

func reparent(node, poc):
    print(poc - self.position)
    var loc = poc - self.position 

func _physics_process(delta):
    rotation = rotation_speed * delta * rotation_dir
    velocity = move_and_collide(velocity * delta)
    if velocity:
        call_deferred("reparent", velocity.collider.get_child(0), velocity.collider.position)      

This is what I'm currently using for the reparenting the child CS2D from it's own entity to the character.

I'd appreciate any and all advice! Cheers

in Engine by (19 points)

1 Answer

0 votes
Best answer

I'm stupid, I changed a ton of things but the major difference was using



by (19 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.