Lerp Camera between 2 moving points on a defined path
Hi all, I have been really struggling with my camera movement and need some help! The whole square rotates clockwise around Point R when player presses the Right key The square can be rotated infinite amount of time and I want the camera to move as if it has gravity
if the square rotates 90 deg, cam moves from Point A to B (smoothly)
if the square rotates 270 deg, cam moves from Point B to A (smoothly)
Here is an image to explain better https://www.facebook.com/photo.php?fbid=10158179885810352&set=gm.1576462965749920&type=3&theater
I have already tried moveTowards but the camera goes completely wild and doesn't move in a straight line that I have defined.
void MoveClockWise()
{
//this rotates the entire square
mySquare.transform.RotateAround(R.position, new Vector3(0.0f, 0.0f, 1.0f), -100 * Time.deltaTime);
//set the step, not sure if the calculation is correct :(
float step = mySpeed*Time.deltaTime;
//and move camera
myCamera.transform.position = Vector3.MoveTowards(myCamera.transform.position, PointB.position, step);
}
Any help would be appreciated. Thanks!
should the camera move from a to b during a 360 of the cube, or 90°? what does it do if the cube goes even further than that? is the cube restricted in rotation?
@hexagonius the cube can be rotated infinite amount of time and the camera moves as if it has gravity
if the cube rotates 90 deg, cam moves from Point A to B
if the cube rotates 270 deg, cam moves from Point B to A
Your answer
Follow this Question
Related Questions
How to fix player camera shaking 0 Answers
CineMachine Virtual Camera distance 0 Answers
Camera does not follow player properly 0 Answers
Make camera follow and look at object at the same time 0 Answers
How to set movement limit to Camera in a top-down 3D game 0 Answers