Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Player : MonoBehaviour
  6. {
  7. public float velocidadY;
  8. public float maxY;
  9. private float posY;
  10. private float direction;
  11.  
  12. // Update is called once per frame
  13. void Update()
  14. {
  15.  
  16. direction = Input.GetAxis("Vertical");
  17.  
  18. posY = transform.position.y + direction*velocidadY*Time.deltaTime;
  19.  
  20. if(posY>maxY){
  21. posY = maxY;
  22. }else if(posY<-maxY){
  23. posY = -maxY;
  24. }
  25.  
  26. transform.position = new Vector3(transform.position.x, posY, transform.position.z);
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement