Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Starting and ending positions of the elevator
- private Vector3 StartPosition;
- private Vector3 EndPosition;
- // Use this for initialization
- void Start () {
- //Set the elevator's starting position
- StartPosition = gameObject.transform.position;
- //We are assuming the elevator is moving along the vertical axis
- EndPosition = gameObject.transform.position;
- EndPosition.y += ElevatorMoveDistance;
- }
- // Update is called once per frame
- void Update () {
- if(bElevatorMovingUp)
- {
- Vector2.Lerp(StartPosition, EndPosition, 5);
- }
- }
- //Called whenever our collider is entered
- void OnTriggerEnter(Collider Collider)
- {
- bElevatorMovingUp = bElevatorMovingUp ? false : true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement