cancel
Showing results for 
Search instead for 
Did you mean: 

CameraRig rotation and Vector3 math

PamelaFFS
Explorer
First my disclaimer: I'm really bad at Vector3 math...

I want the player to be able to rotate their play area with the thumbstick. The issue is that my collision detection doesn't work correctly once the player area is rotated.

For example, if I rotate the cameraRig 180 degrees, I notice that the collision detection seems to think the player is in the opposite end of the play area (mirrored). Somehow I know I need to take the cameraRigs rotation into account, but as I said, I'm really bad at Vector3 math.
here is the code.

                    Vector3 p1 = cameraRig.transform.position + playerBodyCollider.center + Vector3.up * (-playerBodyCollider.height);
                    Vector3 p2 = p1 + Vector3.up * (playerBodyCollider.height);
                    colliders = Physics.OverlapCapsule (p1, p2, playerBodyCollider.radius, layerMask);

                    if (colliders.Length > 0) { // if true, player is colliding with wall
                        result = true;
                    }
1 REPLY 1

PamelaFFS
Explorer
Looks like I found the issue...not sure why I didn't see it before...I just needed to remove the cameraRig from the equation