Question by
CreativeThinking · Dec 10, 2015 at 05:54 AM ·
c#touchrotatedelta position
Stop rotation past a certain point with touch
I'm trying to figure out how to rotate my object until it reaches a certain point. Would something like this need to be accomplished using position? Or would I need to do some editing of my code. Basically, my plane is going up and down and rotating in circles, BUT I dont want it to do that. I want it to stop rotating past a certain point and stay until changed by touch. Please help me! I'm very new to Unity.
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
// Get movement of the finger since last frame
Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
// Move object across XY plane
transform.Translate(0, touchDeltaPosition.y * speed * Time.deltaTime, 0);
transform.Rotate(0, 0, touchDeltaPosition.y/2);
}
img-1700.jpg
(132.8 kB)
Comment