- Home /
Question by
RurouniKen · Oct 07, 2019 at 08:52 PM ·
rotatejoystickrotate objectrotatearoundorbit
Joystick Rotation with Transform.RotateAround
So I want to rotate an object around other that matches my current joystick rotation. I know Transform.RotateAround around does this but I can't seem to find a way to match it with my joystick rotation.
This following code rotates an object by matching the current joystick rotation, How can I achieve the same function but with the Transform.RotateAround?
protected Vector2 aimDirection; //direction the cat is pointing, jump direction
protected float aimAngle;
protected Quaternion aimRotation;
void FixedUpdate()
{
float TurnV = Input.GetAxis("TurnV");
float TurnH = Input.GetAxis("TurnH");
aimDirection = new Vector2(TurnH, TurnV);
aimAngle = Mathf.Atan2(TurnH, TurnV) * Mathf.Rad2Deg;
if (TurnV != 0 && TurnH != 0)
{
aimRotation = Quaternion.AngleAxis(aimAngle, Vector3.forward);
transform.rotation = Quaternion.Slerp(transform.rotation, aimRotation, turnSpeed * Time.time);
}
Comment
Your answer
Follow this Question
Related Questions
Camera Orbit Rotation Problem 0 Answers
Rotate object in the direction where it is going 1 Answer
Flying player Rotates in the left and right direction not forward and back 1 Answer
how to change orbit direction when button clicked? 0 Answers
Quaternion, eulerAngles, localEulerAngles Driving me mad 1 Answer