The question is answered, right answer was accepted
Turning plane at an angle instead of rotating around center
Hey there, so I've got a script that controls Plane movements, and virtual joystick that takes care of it, and it's cool, but I'd like my plane to be controlled somewhat like it's controlled by mouse in WarThunder.
If you don't know what I'm on about here is the video. https://www.youtube.com/watch?v=xxEgQWomxXU
Right now I'm using basic stuff:
transform.position += transform.forward * Time.deltaTime * speed;
transform.Rotate(-CrossPlatformInputManager.GetAxis("Vertical"), 0.0f, -CrossPlatformInputManager.GetAxis("Horizontal"));
So basically when I want to go left, instead of rotating around the center of the plane like I'm doing right now, I want the plane to turn left at an angle. How can I achieve that?
Cheers
Answer by gorbit99 · Feb 11, 2016 at 05:25 PM
transform.RotateAround(gameObjectPos, pointToRotateAround, AmountOfRot);
Hey man nice one, just one more thing - do you know how to lock the plane from rotating too far around it's center while turning? Let's say I'd like it to rotate around it's center only by 60 degrees when turning.
That's what I've got now:
transform.RotateAround(transform.position, Vector3.up, Input.GetAxis("Horizontal") * 30f * Time.deltaTime);
transform.Rotate(-Input.GetAxis("Vertical"), 0.0f, -Input.GetAxis("Horizontal") * 1.5f);
Follow this Question
Related Questions
why Plane disappear in unity when export from 3ds Max to Unity? 0 Answers
How to change the position of a button? 1 Answer
Baked lightmap in unity 5.2 not affect on android device 2 Answers
Game Scene lags while starting 0 Answers
Help with Pause Menu 1 Answer