Hi all.
My first question here, so please do correct me if I'm wrong.
I'm trying to temporarly join my player (RigidBody2D) with the map's walls (TileMap).
I managed to do this with other RigidBody2Ds, but I don't know how to do it with the TileMap node.
When my player is colliding with the TileMap I can see PinJoint2D properly on screen (Debug -> Visible Collision Shape), but the player's physics are still going. Here's a little snippet of how I do it in player script:
func pin(body) -> void:
if pin1 != null:
return
pin1 = Elementer.pin(self, body, position)
pin2 = Elementer.pin(self, body, body.position)
And here is what Elementer.pin looks like:
func pin(objA, objB, pos: Vector2):
var pin = PinJoint2D.new()
pin.position = pos
pin.node_a = objA.get_path()
pin.node_b = objB.get_path()
levelNode.add_child(pin)
return pin
Please consider that this is working very well on multiple scenarios when two RigidBody2Ds are in question.
I did think about changing the palyer's mode from rigid to static, but it looks like a hack to me, even tho it is true that my TileMap isn't going anywhere unlike other RigidBody2Ds that my player can hang on to.