- Home /
How can i move the camera smooth like flow up and behind the player when clicking the escape key ?
Today when i'm running the game it start with the camera very close to the player. This should be for the main menu view. Now i want to do that when i click once the escape key it will resume the game in a way that the camera will flow up and back of the player and will show the whole terrain and game area. And if i click the escape key again the camera will flow again back to the player very close to him.
It should be like that in every point/place in the game. This is like a switching between main menu and the game playing mode.
I didn't make yet the main menu. For now i want to make the escape key switching between close view on the player that will be the main menu mode/screen and clicking again the escape key back to game play mode.
I didn't make a lot yet with this:
Now if i click the escape key i want the camera to flow smooth up and behind the player i think this is the position the camera should be to play i mean in playing mode.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MainMenu : MonoBehaviour {
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
Debug.Break(); // to make here a switching mode between
//playing screen and pause/main menu screen.
}
}
}
I used now Time.timeScale anda count variable. so now the pause is working but i don't want to freeze everything when clicking the escape key. I want that when it's 0 pause so everything will be on idle mode not stopped mode.
So i guess using the Time.timeScale is not the right way.
And yet i'm not sure how to move the camera.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class $$anonymous$$ain$$anonymous$$enu : $$anonymous$$onoBehaviour {
int count = 0;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Escape))
{
if (count == 0)
{
Time.timeScale = 0;
count = 1;
}
else
{
Time.timeScale = 1;
count = 0;
}
// to make here a switching mode between
//playing screen and pause/main menu screen.
}
}
}