SceneUp.cs 550 B

123456789101112131415161718192021222324
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SceneUp : MonoBehaviour
  5. {
  6. public float speed;
  7. // Start is called before the first frame update
  8. void Start()
  9. {
  10. }
  11. // Update is called once per frame
  12. void Update()
  13. {
  14. if (PlayersInput.instance[0] == null)
  15. {
  16. return;
  17. }
  18. speed = (PlayersInput.instance[0].transform.position.y - transform.position.y)/2f;
  19. transform.position += Vector3.up * Time.deltaTime * speed;
  20. }
  21. }