Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Player : MonoBehaviour
- {
- public float moveSpeed = 3f;
- public GameObject raycastStart;
- private float minHeight = 1.15f;
- private float maxHeight = 1.3f;
- private bool tpCheck;
- private Vector3 lastGoodPos;
- void FixedUpdate()
- {
- transform.Translate(Vector3.forward * Time.deltaTime * Input.GetAxis("Vertical") * moveSpeed);
- transform.Translate(Vector3.right * Time.deltaTime * Input.GetAxis("Horizontal") * moveSpeed);
- if (Physics.Raycast(raycastStart.transform.position, Vector3.down, 0.2f))
- {
- lastGoodPos = transform.position;
- }
- else
- {
- transform.position = lastGoodPos;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement