Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 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 moveSpeed = 3f;
  8. public GameObject raycastStart;
  9.  
  10. private float minHeight = 1.15f;
  11. private float maxHeight = 1.3f;
  12. private bool tpCheck;
  13.  
  14. private Vector3 lastGoodPos;
  15.  
  16. void FixedUpdate()
  17. {
  18. transform.Translate(Vector3.forward * Time.deltaTime * Input.GetAxis("Vertical") * moveSpeed);
  19. transform.Translate(Vector3.right * Time.deltaTime * Input.GetAxis("Horizontal") * moveSpeed);
  20.  
  21.  
  22.  
  23.  
  24. if (Physics.Raycast(raycastStart.transform.position, Vector3.down, 0.2f))
  25. {
  26. lastGoodPos = transform.position;
  27. }
  28. else
  29. {
  30. transform.position = lastGoodPos;
  31. }
  32.  
  33.  
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement