Question by
xzarations · Apr 23, 2021 at 01:02 AM ·
rotationphysicsvrrotatearoundangleaxis
AngleAxis and MoveRotation not rotating around the object
I am trying to use physics to rotate the player based on the location of the camera. I am 90% sure I have everything set up correctly as I have test and messed around for about 2 hours. I can't seem to figure out why it won't rotate based on the location of the forwardAxis(camera). it rotates just like how I want with the joystick but the issue is that is doesn't based on the forwardAxis location. Can anyone spot what I did wrong because I have been researching for some time and I really just can't pinpoint why it won't work.
Vector3 rot;
public Transform forwardAxis;
public float rotateSensitivity;
Quaternion q;
public SteamVR_Action_Vector2 joystick;
Rigidbody rb;
private void Update()
{
positionCalculator();
rotationCalculator();
}
private void FixedUpdate()
{
updatePosition();
updateRotation();
}
void rotationCalculator()
{
rot = new Vector3(joystick[rotation].axis.x, 0, 0);
q = Quaternion.AngleAxis(rot.x * rotateSensitivity, forwardAxis.up);
}
void updateRotation()
{
rb.MoveRotation(rb.transform.rotation * q);
}
Comment