Hi all ![]()
I’m working on a 2D swinging/grappling game using HingeJoint2D.
I have a GameObject with a Rigidbody2D attached and a script which creates a HingeJoint2D component at run time. As long as you hold down the mouse button you would swing off the ceiling of the level. While the GameObject is swinging, the sprite and collider attached is rotating in orientation to the grapple point.
I’ve tried countering this by separating the sprite and collider as a separate GameObject attached as a child of the main GameObject and applying transform.rotation = Quaternion.identity to stop the rotation as it would otherwise use the rotation of the parent GameObject, and this semi works most of the time until I start colliding with things, and the GameObject would start just going crazy, defying its gravity or gets a constant upwards force for some reason.
I also tried just separating the sprite+collider completely (not parented) and just keep the two positions together in script, however this of course can’t work as the collider needs to be attached to the rigidbody (or at least as a child object) otherwise collisions cannot occur.
How should I do this?![]()