Making object move up and down in Y axis while rotating down and up
Im trying to figure out how to make my plane object rotate and go up and down in the Y axis with touch on a mobile device. It is a little laggy and it goes backwards in the Z direction too much so when you start to go down it will rotate in a full circle instead of smoothly going down and up in the Y axis. What I want to accomplish is have the plane go down in a smooth direction while rotating down and up slowly, but it is very laggy and slow. Here is my code to show an example of what I'm talking about:
public float speed = 0.1f;
public static int forwardSpeed = 20;
public Vector3 userDirection = Vector3.right;
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, 0);
transform.Rotate(0, 0, touchDeltaPosition.y * speed/0.8f);
}
Answer by IsaacHoward · Dec 10, 2015 at 01:45 AM
Im making an rpg and i used this tutorial to move https://youtu.be/XZDjkQ8wEd0?list=PL_4rJ_acBNMH3SExL3yIOzaqj5IP5CJLC&t=891 hope it helps
@IsaacHoward thank you for the video is was pretty helpful, but I'm looking to change the position of the plane using touch. How would I do so using this?
i do not know iv never used touch controls but if its like pressing a key i would implement it into the
Vector2 movement_vector = new Vector2(Input.GetAxisRaw("Horizontal") , Input.GetAxisRaw("Vertical"));
//if not zero must be moving
if (movement_vector != Vector2.zero)
{
anim.SetBool("isWalking", true);
anim.SetFloat("input_x", movement_vector.x);
anim.SetFloat("input_y", movement_vector.y);
}
else //sees if in idel or not changes anim
{
anim.SetBool("isWalking", false);
}
you will probably have to do some messing around
Your answer
Follow this Question
Related Questions
how to rotate a mesh with GetMouseButton with specific rotation value 2 Answers
how do I rotate an object without affecting later rotation? 0 Answers
when trying to rotate, the object transforming itself 0 Answers
Rotating an object with VR controller 1 Answer
Simple Rotate Script won't work! 2 Answers