Hi, I’m quite new about unity and I cannot figure out how to make my camera move and rotate at the same time when I click a specific button on my interface.
Let me explain more in detail what I need.
I’ve added a GUI interface in my project and when I press a specific button, I want that my camera makes a smooth movement while adjusting its rotation (and maybe its field of view).
The problem is that all those translations and rotations happen along more than one axes:
- start position (0,800,610)
- start rotation (55,180,0)
- final position (-200,800,1000)
- final rotation (45,150,0)
I’ve found a lot of information about how to make GameObjects move or rotate using mouse coordinates, but not one matched my need.
Does someone know how to solve this problem with a script?
EDIT:
this is the function I wrote
function CameraMovement()
{
var startTime = Time.time;
var startPoition = movementTarget.transform.position;
var targetPosition = GameObject.Find("main_cam").transform.position;
while (Time.time<startTime+1.5)
{
var i=(Time.time - startTime);
movementTarget.transform.position = Vector3.Lerp(startPosition, targetPosition, i);
yield;
}
}
It is triggered by one of the buttons in my GUI and it realize only a smooth translation.
Do you know how can I improve it to have also the rotation?