Hey guys, I am having a bit of an issue with CineMachine. I just installed the extension yesterday and followed the Unity tutorial to set it up, which works perfectly. I really enjoy the dead zones and such. However, I am having an issue with follow ahead as well as my death respawn.
- I had a scrip within my old camera making it so the camera followed ahead whichever way I was facing on the X axis.
public class CameraController : MonoBehaviour {
public GameObject target;
public float followAhead;
private Vector3 targetPosition;
public float smoothing;
public bool followTarget;
// Use this for initialization
void Start () {
followTarget = true;
}
// Update is called once per frame
void Update () {
if (followTarget) {
targetPosition = new Vector3 (target.transform.position.x, target.transform.position.y + 1, transform.position.z);
//this moves the target of the camera ahead of the player
if (target.transform.localScale.x > 0f) {
targetPosition = new Vector3 (targetPosition.x + followAhead, targetPosition.y, targetPosition.z);
} else {
targetPosition = new Vector3 (targetPosition.x - followAhead, targetPosition.y, targetPosition.z);
}
//transform.position = targetPosition;
transform.position = Vector3.Lerp (transform.position, targetPosition, smoothing * Time.deltaTime);
}
}
}
I just can’t figure out how to make a smooth follow ahead with using CineMachine.
- The second issue I am having is on my respawn. I have certain flag points, which when you walk past are activated and reset on death. When you die, you respawn at the last flag. I do still respawn, but it takes the cinemachine camera a second to re-focus on my player, which makes the screen kind of shaky and weird for a split second.
Here is my respawn coroutine.
//Coroutine function, Player deacti. on KillPlane with delay, then reacti.
public IEnumerator RespawnCo(){
respawnCoActive = true;
thePlayer.gameObject.SetActive (false);
//thePlayer.transform.SetParent(null);
Instantiate (deathSplosion, thePlayer.transform.position, thePlayer.transform.rotation);
yield return new WaitForSeconds (waitToRespawn);
respawnCoActive = false;
healthCount = maxHealth;
respawning = false;
UpdateHeartMeter ();
coinCount = 0;
coinText.text = "Coins: " + coinCount;
coinBonusLifeCount = 0;
thePlayer.transform.position = thePlayer.respawnPosition;
thePlayer.gameObject.SetActive (true);
for (int i = 0; i < objectsToReset.Length; i++) {
objectsToReset [i].gameObject.SetActive (true);
objectsToReset [i].ResetObject ();
}
}
Is there a way around this? Maybe make a different respawn? Thank in advance.