Advertisement
Zenn_

NPC.cs

Jun 18th, 2017
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class NPC : MonoBehaviour {
  6.     protected Rigidbody thisRigidbody;
  7.     protected Collider thisCollider;
  8.     protected Vector3 thisPosition
  9.     {
  10.         get
  11.         {
  12.             return this.gameObject.transform.position;
  13.         }
  14.         set
  15.         {
  16.             gameObject.transform.position = value;
  17.         }
  18.     }
  19.     protected Quaternion thisRotation
  20.     {
  21.         get
  22.         {
  23.             return this.gameObject.transform.rotation;
  24.         }
  25.         set
  26.         {
  27.             gameObject.transform.rotation = value;
  28.         }
  29.     }
  30.     protected Vector3 thisVelocity
  31.     {
  32.         get
  33.         {
  34.             return thisRigidbody.velocity;
  35.         }
  36.         set
  37.         {
  38.             thisRigidbody.velocity = value;
  39.         }
  40.     }
  41.     protected Vector3 thisForwardVector
  42.     {
  43.         get
  44.         {
  45.             return this.gameObject.transform.forward;
  46.         }
  47.     }
  48.     protected Vector3 thisRightVector
  49.     {
  50.         get
  51.         {
  52.             return this.gameObject.transform.right;
  53.         }
  54.     }
  55.     protected DebugLogConsole debugLogConsole;
  56.  
  57.     // Use this for initialization
  58.     protected void Start () {
  59.         thisRigidbody = this.gameObject.GetComponent<Rigidbody>();
  60.         thisCollider = this.gameObject.GetComponent<Collider>();
  61.         debugLogConsole = GameObject.Find("master").GetComponent<masterScript>().debugLogConsole;
  62.     }
  63.  
  64.     public void addVelocity(Vector3 vel)
  65.     {
  66.         thisVelocity += vel;
  67.     }
  68.     public void setVelocity(Vector3 vel)
  69.     {
  70.         thisVelocity = vel;
  71.     }
  72.     public void turn(float x = 90, float y = 0, float z = 0)
  73.     {
  74.         thisRotation *= Quaternion.Euler(x, y, z);
  75.     }
  76.     public void teleport(float x = 0, float y = 0, float z = 0)
  77.     {
  78.         thisPosition = new Vector3(x, y, z);
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement