- Home /
Physic Collider Test Rotation
Hi,
In my game, I am rotating a parent gameobject with 4 child gameobjects, all with rigidbodies and box colliders attached, in 90 degree intervals.
What I need to know is if there is a way in Unity to almost do like a physics "arc" cast to test if any of the child gameobjects will collide with other colliders in my scene along the path of it's rotation, without actually performing the rotation.
My code will actually jump straight between 90 degree intervals so I need a way to interpolate an arcing path from one rotation to the next and test for collisions.
Any help on this matter would be appreciated. Here is a small snippet of my code so far. gamePieceEuler represents pre-calculated degree-based rotation values for each axis, all of which will be in 90 degree intervals (ie. 90, 180, 270, 360)
Debug.Log("Game Piece Rotation:\r\nX: " + gamePieceEuler.x + "\t\tY: " + gamePieceEuler.y + "\t\tZ: " + gamePieceEuler.z);
if(controllerState == ControllerReadState.Rotating)
{
if(gamePieceEuler != Vector3.zero)
{
currentGamePiece.transform.Rotate(gamePieceEuler, Space.World);
}
}
Your answer
Follow this Question
Related Questions
Rigidbody doesn't rotate after collision 3 Answers
Rigidbodies won't collide if mass difference is too high 0 Answers
Physics.CapsuleCast Help 1 Answer
Guidelines for using rigidbody, collider, CharacterControllerScript, etc? 3 Answers
how to change physics material of a colider in runtime 5 Answers