- Home /
Question by
mifanfeed · Sep 18, 2019 at 04:44 PM ·
rotationtransformquaternionjointsconfigurablejoint
How to fix this strange child 3D rotation?
Hi! I am having an issue with a rotation and childs. I am trying to implement swinging mechanics, and it has to work like this: Player presses LMB, and the player (red cube here) becomes a child of a big scaled cyllinder which has configurable joint and is a child of another empty object which is his connected body. The problem is, when the cube becomes a child, his rotation goes weird
How can I fix it?
Here are key moments in scripts:
if (Input.GetMouseButtonDown(0)) {
transform.SetParent(Parent); // setting the player's Parent
rb.isKinematic = true; //Iso that player wont fall down
swing.enabled = true; //activaating Swing script
_Start = false; //disabling movement
}
And here it is the script which makes the cyllinder move/rotate (adds force and it works like a rope)
void Update () {
Horizontal = Input.GetAxis("Horizontal") * Accel;
Vertical = Input.GetAxis("Vertical") * -Accel;
Force();
}
public void Force() {
rb.AddForce(transform.forward * Horizontal, ForceMode.Impulse);
rb.AddForce(transform.right * Vertical, ForceMode.Impulse);
}
screenshot-14.png
(92.6 kB)
Comment
This behaviour can occur if you the object itself or one of its parent does not have an homogeneous scale (if the 3 components of the scale are not the same)