Bumper.cs 775 B

12345678910111213141516171819202122232425262728293031
  1. using Assets.StreetLight.Scripts;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. public class Bumper : MonoBehaviour
  7. {
  8. public bool isBump1;
  9. public float speed = 5f;
  10. PersonManager PersonManager => personManagerLazy.Value;
  11. Lazy<PersonManager> personManagerLazy;
  12. private void Awake()
  13. {
  14. personManagerLazy = new Lazy<PersonManager>(FindObjectOfType<PersonManager>);
  15. }
  16. void Update()
  17. {
  18. if (isBump1)
  19. {
  20. transform.Translate(0f, Input.GetAxis("Vertical") * speed * Time.deltaTime, 0f);
  21. }
  22. else
  23. {
  24. //transform.Translate(0f, Input.GetAxis("Vertical2") * speed * Time.deltaTime, 0f);
  25. }
  26. }
  27. }