Guest User

Untitled

a guest
Dec 12th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5.  
  6. public class LocalGravity:MonoBehaviour {
  7.     public LayerMask gravMeshLayer;
  8.     public float gravityDistance = 10.0f;
  9.     public float rotationSpeed = 4.0f;
  10.     public void Update() {
  11.         RaycastHit hit;
  12.         if (Physics.Raycast(transform.position,-transform.up,out hit,gravityDistance,gravMeshLayer)) {
  13.             float distRatio = hit.distance/gravityDistance;
  14.             transform.up = Vector3.Slerp(transform.up,hit.normal,Time.deltaTime*rotationSpeed);
  15.         }
  16.     }
  17. }
Add Comment
Please, Sign In to add comment