The camera move with the mouse pointer by using:
public class cam : MonoBehaviour {
public static Vector3 Point;
public float yDis;
void FixedUpdate(){
var mousePos = Input.mousePosition;
Point=camera.ScreenToWorldPoint(new Vector3(mousePos.x,mousePos.y,yDis));
transform.LookAt(Point);
}
}
It works but the screen moves really fast, too fast to be able to play properly. Is there any way to slow it down?
CodePudding user response:
Use Quaternion.FromToRotation and then use Quaternion.Lerp. try this.
Vector3 relativePos = focus.position - transform.position;
Quaternion toRotation = Quaternion.LookRotation(relativePos);
transform.rotation = Quaternion.Lerp( transform.rotation, toRotation,
1 * Time.deltaTime );
CodePudding user response:
I would try:
void FixedUpdate(){
var mousePos = Input.mousePosition;
Point=camera.ScreenToWorldPoint(new Vector3(mousePos.x,mousePos.y,yDis));
transform.rotation = Quaternion.Lerp(transform.rotation, Point.rotation, 0.05f);
}