- Home /
Swipe angle and Rotation of camera to movement
Hi,
I have a camera and a cube. when the game starts the camera is at (1,1,-2) position and (0,0,0) rotation and shows the cube.
Whenever I swipe I rotate the camera around the cube, while the cube's center is the center of rotation.
I want to move the cube in the correct direction using the swipe vector/angle(which I already have) and camera roation. the direction should be one of (1,0,0) / (0,1,0) / (0,0,1) and the opposite directions (-)
Anyone can help me with how to do this? using vector/angle(0-360) and the camera rotation to understand which direction the cube should move?
thank you!!
(I have a toggle that decideds which action swipe does)
Answer by Sponxie · Nov 11, 2021 at 06:00 PM
You can move the cube with transform.Translate(Camera.main.transform.forward * speed * Time.deltaTime);
Where speed is the parameter speed for how fast you want to travel.
Hey thanks for your answer. but that does not consider the gesture direction. also it's not necessarily (1,0,0) / (0,1,0) / (0,0,1) etc..