Advertisement
djgaven588

Minecraft Collision Engine - Dynamic Collider

Aug 1st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5.  
  6. public class DynamicCollider : MonoBehaviour {
  7.  
  8.     public Vector3 colliderSize;
  9.     public Vector3 colliderOffset;
  10.  
  11.     public Vector3 velocity;
  12.     public Vector3 hitNormal;
  13.     public bool isRegistered;
  14.  
  15.     void OnEnable ()
  16.     {
  17.         CollisionEngine.RegisterDynamicCollider(this);
  18.     }
  19.  
  20.     void OnDisable()
  21.     {
  22.         CollisionEngine.UnregisterDynamicCollider(this);
  23.     }
  24.  
  25.     void OnDestroy()
  26.     {
  27.         CollisionEngine.UnregisterDynamicCollider(this);
  28.     }
  29.  
  30.     public void PhysicsUpdate (float time)
  31.     {
  32.         velocity = new Vector3(Input.GetAxisRaw("Horizontal"), velocity.y, Input.GetAxisRaw("Vertical"));
  33.         if (Input.GetKeyDown(KeyCode.Space))
  34.         {
  35.             velocity.y = 4;
  36.         }
  37.         else
  38.         {
  39.             velocity.y -= 1 * time;
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement