CameraSnake.cs 557 B

12345678910111213141516171819202122232425
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class CameraSnake : MonoBehaviour {
  5. float tick = 0;
  6. float rotZ = 0;
  7. // Use this for initialization
  8. void Start () {
  9. }
  10. // Update is called once per frame
  11. void Update () {
  12. tick += Time.deltaTime;
  13. rotZ += 0.02f;
  14. Vector3 pos = transform.position;
  15. pos.y = Mathf.Sin(tick / 10f) * 8f;
  16. transform.rotation = Quaternion.Euler(0 , Mathf.Sin(tick/5f) /5f * Mathf.Rad2Deg ,rotZ);
  17. transform.position = pos;
  18. }
  19. }