void recoilForward() { move = recoilmove.forward; // Start coroutine to move the camera down smoothly over time Vector3 zoomInOffset = new Vector3(0f, 0f, 0.5f); Vector3 zoomInWorldPosition = transform.TransformDirection(zoomInOffset); // Move the camera smoothly StartCoroutine(MoveToPosition(transform.position + zoomInWorldPosition, recoilSpeed)); }
public void recoilBack() { timer = snapback; move = recoilmove.back; // Start coroutine to move the camera up smoothly over time Vector3 zoomOutOffset = new Vector3(0f, 0f, -0.5f); Vector3 zoomOutWorldPosition = transform.TransformDirection(zoomOutOffset); // Move the camera smoothly StartCoroutine(MoveToPosition(transform.position + zoomOutWorldPosition, recoilSpeed)); }
void Update() { if (done && move == recoilmove.def) { transform.localPosition = ogpos; done = false; } else if (move == recoilmove.back) { timer -= Time.deltaTime; if (timer <= 0f) { recoilForward(); move = recoilmove.def; } } }