Godot Version
Godot 4 (probably)
Question
Why does an Area2D stop a RigidBody2D from dynamicly (?) rotating and how can I make it so that the RigidBody2D still freely moves?
Hello! I have a hammer that should move around the player (moving because the attachment point moves) using a PinJoint2D, but when I add an Area2D to the hammer head, it doesn’t move when moved, only when colliding!
It is structured like this:
→ Node2D (Base of the hammer)
→ -> StaticBody2D (Attachment for the pin)
→ -> → CollisionShape2D (Really doesn’t do anything)
→ -> RigidBody2D (the other attachment for the pin)
→ -> → CollisionShape2D (The head of the hammer)
→ -> → Sprite2D (The hammer sprite)
→ -> PinJoint2D (Attaches to Staticbody and Rigidbody)
^ This works perfectly fine unless I try to attach an Area2D to the hammer head. When I attach it as a child to either the Sprite2D or RigidBody2D the whole hammer stops moving (unless it collides with something)! I need the area2D to stay on the end of the hammer so I can use it to detect when colliding with enemies.
(The Area2D is a hurtbox/hitbox module (?) with a CollisionShape2D)
What could I do to fix this?
In the code there is just a process() that moves the Node2D to the player.
(Sorry if this is badly written, it is my first english internet post)
Area2d also needs a collision shape. And as far as I know should not cause this issue.
Thanks for the reply, but I have given the Area2D a CollisionShape2D. I’ve also tried moving it around in the tree. It seems to only stop the rotation when the Area2D is a child of the RigidBody2D, or a child of a child of a RigidBody2D. If I have the Area2D as a child of the Node2D or any other nodes that don’t belong to the RigidBody2D, it doesn’t stop rotating.
I did more testing and found out that the Area2D only stops the rotational movement caused by the player moving around (which I don’t want it to do). But it does rotate if I add force manually and if it collides with something!
Oh you may want to change the areas gravity attributes, angular damping etc. these will effect bodies inside it.
Just make sure the damp and gravity overrides are disabled.
I’ve looked around the settings, and tried pretty much everything in the inspector. Right now I have the Area2D connected to the main Node2D, and have a script to move it on the head of the hammer manually. It’s a bit clunky but it works for now.
If anyone has a better solution to the problem, feel free to share!
It all works in 4.2.2 without modifying any properties.
I can’t upload a video yet (I’m a new user), but my problem is that the hammer should move around based on the movement of the base attachment which is the player. The hammer moves well when the Area2D is not connected to the RigidBody2D, but when it is, it doesn’t move unless you manually give it force or make the head of the hammer collide with something. I need it to move dynamicly (?) with the movement of the player, because I want the player to move around to gain momentum for the hammer (angular velocity). But still I am very thankful that you are trying to help me.