- Home /
Question by
alexdevAo · Apr 08, 2020 at 01:20 AM ·
transform.rotationridgidbody
How to get the exact rotation that is in Transform?
I used Rigidbody.angularVelocity to make the game object rotate, and when I go to get the object's rotation, I get a different rotation than the Transform
Comment
Answer by Vipertex13 · Apr 08, 2020 at 05:24 AM
@alexlukanga
Hello!
I assume your code is not correct so I found out this way to find the rotation of an object
float x;
void Update ()
{
x += Time.deltaTime * 10;
transform.rotation = Quaternion.Euler(x,0,0);
}
Hope This Helps!
Thanks @Vipertex13
I would like the rotation to be according to the Swipe Count. And don't rotate all the time
void Update()
{
// Calculate the distance
swipeDelta = Vector2.zero;
if(isDraging)
{
if (Input.touchCount > 0)
{
swipeDelta = Input.touches[0].position - startTouch;
}
else if (Input.Get$$anonymous$$ouseButton(0))
{
swipeDelta = (Vector2)Input.mousePosition - startTouch;
}
}
// Did we cross the deadzone
if (swipeDelta.magnitude > 125)
{
// Which direction?
x = swipeDelta.x;
y = swipeDelta.y;
if($$anonymous$$athf.Abs(x) > $$anonymous$$athf.Abs(y))
{
// Left or Right
}
else
{
// Up or Down
if (y > 0 && canPlay)
{
swipeUp = true;
gameStarted = true;
}
else
swipeDown = true;
}
if (swipeUp)
{
gameObject.GetComponent<Rigidbody>().velocity = new Vector3(0, upSpeed * y * Time.deltaTime, 0);
gameObject.GetComponent<Rigidbody>().angularVelocity = new Vector3(rotateSpeed * y * Time.deltaTime, 0, 0);
swipeUp = false;
y = 0;
x = 0;
}
}
Debug.Log(transform.eulerAngles);
}
I'm getting a different angle
Sorry I am not that good at mobile games and haven't learned swipe yet
Sorry
Your answer
