Targeting Player when Zooming Camera
I am zooming Camera when player dies, but it rotates entire screen, that is not preferable. Is there any way to zooming camera, as well as targeting player. The following code I've used for zooming and targeting.
IEnumerator ZoomIn()
{
while (GameCamera.orthographicSize > 2) {
yield return new WaitForSeconds (0.01f);
transform.LookAt (PlayerTransform [GameController.instance.GetSelectedBird ()], transform.up);
GameCamera.orthographicSize -= 0.1f;
}
}
public void ZoomCamera()
{
StartCoroutine (ZoomIn ());
}
I am also putting player running code.
void FixedUpdate () {
if (isAlive) {
Vector3 temp = transform.position;
temp.x += forwardSpeed * Time.deltaTime;
transform.position = temp;
if (didFlap) {
didFlap = false;
myRigidBody.velocity = new Vector2 (0, bounceSpeed);
audioSource.PlayOneShot (flapClip);
anim.SetTrigger ("Flap");
}
if (myRigidBody.velocity.y >= 0) {
transform.rotation = Quaternion.Euler (0, 0, 0);
} else {
float angle = 0;
angle = Mathf.Lerp (0,-90,-myRigidBody.velocity.y/7);
transform.rotation = Quaternion.Euler (0,0,angle);
}
}
}
Comment