Would pause the Start() for 2 secs while the camera moves into position, then continue with the rest of the combat script.
How the heck do i achieve that in C#. I’ve been playing with StartCoroutines and it just doesn’t work the same. I just want to pause the script to let the camera move, then resume.
the C# moves the camera, but doesn’t pause the script. Please help.
void Start () {
StartCombat();
CombatCameraController combatCameraController = combatCamera.GetComponent<CombatCameraController>();//move combat camera
StartCoroutine(combatCameraController.MoveFromToPosition(transform.position, transform.TransformPoint(4,6,0), 2.0f));
StartCoroutine(combatCameraController.RotateToObject(transform, 2.0f));
// yield return new WaitForSeconds(2.0f); no workie
If you didn’t want to use yield inside another coroutine you can do what I usually do.
You can create two variables, one that lets you know if you should be moving the camera, and one to know if you should continue with the script.
So in your update you have
if(movingCamera){
//code to move camera
if (Mathf.Abs((Camera.transform.position.x - TheDesiredLocation.position.x)) < 0.05) {
doRestOfCode = true;
movingCamera = false;
}
}
if(doingRestOfCode){
//code to do rest of code
}
And when you want to move your camera make doingRestOfCode equal false and movingCamera equal true. This idea is most effective when you’re using slerp/lerp to move your object.