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 GroundDown : MonoBehaviour {
- public float height = 1.0f;
- void Update () {
- RaycastHit hit;
- Vector3 pos = new Vector3 ( transform.position.x, transform.position.y + height, transform.position.z );
- if ( Physics.Raycast ( pos, -Vector3.up, out hit ) ) {
- if ( hit.distance - height < 0.0f ) {
- transform.position = hit.point;
- } else if ( hit.distance - height > 0.1f ) {
- transform.position -= Vector3.up * 0.1f;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement