- Home /
Question by
Trild123787898 · Nov 18, 2021 at 04:48 PM ·
script.
pause object rotation
Hello, I rotate the joint along the x-axis, I reduced the force so that it could not lift the parent object when it collides with the collider, the problem is that when it collides with the collider, the turn goes further until it reaches -50 and if I make a turn to 50, he goes up, but he starts it then when he reaches a collision value with a collider of about -30, then he goes up. The question is how can I make sure that when the object collides with the collider, it pauses, and can no longer reach the value -50, but at the same time so that it can reach the value 50.
void FixedUpdate()
{
if (Input.GetKey(KeyCode.E))
{
hinge.targetRotation = Quaternion.RotateTowards(hinge.targetRotation, Quaternion.Euler(new Vector3(10,0,0)), 10 * Time.deltaTime);
}
if (Input.GetKey(KeyCode.Q))
{
hinge.targetRotation = Quaternion.RotateTowards(hinge.targetRotation, Quaternion.Euler(new Vector3(-50,0,0)), 10 * Time.deltaTime);
}
}
void OnCollisionEnter(Collision other) {
if(other.collider.tag == "kran")
{
Debug.Log("Good");
}
}
Comment