Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. //Starting and ending positions of the elevator
  2. private Vector3 StartPosition;
  3. private Vector3 EndPosition;
  4.  
  5. // Use this for initialization
  6. void Start () {
  7. //Set the elevator's starting position
  8. StartPosition = gameObject.transform.position;
  9.  
  10. //We are assuming the elevator is moving along the vertical axis
  11. EndPosition = gameObject.transform.position;
  12. EndPosition.y += ElevatorMoveDistance;
  13. }
  14.  
  15. // Update is called once per frame
  16. void Update () {
  17.  
  18.  
  19. if(bElevatorMovingUp)
  20. {
  21. Vector2.Lerp(StartPosition, EndPosition, 5);
  22.  
  23. }
  24. }
  25.  
  26. //Called whenever our collider is entered
  27. void OnTriggerEnter(Collider Collider)
  28. {
  29. bElevatorMovingUp = bElevatorMovingUp ? false : true;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement