Advertisement
Flynny85

can it pass?

May 25th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5.  
  6. #if UNITY_EDITOR
  7. using UnityEditor;
  8. #endif
  9.  
  10. public class test : MonoBehaviour {
  11.  
  12.     public Transform _car1;
  13.     public Transform _car2;
  14.  
  15.     private float _distance_start_hit;
  16.     private float _distance_start_tp;
  17.     private float _distance_tp_hit;
  18.  
  19.  
  20.  
  21.     private float _angle;
  22.  
  23.     public float _length = 1f;
  24.     public float _oppositeLength;
  25.     public float _oppositeAngle;
  26.     public float Check_ObjectIsInPath( Vector3 _position_Start , Vector3 _position_Ahead , Vector3 _position_Target , float _objectRadius){
  27.         _directionForward = _position_Start - _position_Ahead;
  28.  
  29.         _distance_ToTarget_01 = MyMath.Get_XZ_DistanceAccurate(_position_Start , _position_Target);
  30.         _distance_angle_01 = Vector3.Angle (_position_Start - _position_Target, _directionForward);
  31.         // opposite side length we need == sin of angle01 * length of hyp ..
  32.         _oppositeAngle = Mathf.Sin(_distance_angle_01) * Mathf.Rad2Deg;
  33.         _oppositeLength = _oppositeAngle * _distance_ToTarget_01;
  34.         return _oppositeLength;
  35.     }
  36.  
  37.  
  38.     private Vector3 _vect_sp;
  39.     private Vector3 _vect_tp;
  40.     private Vector3 _vect_hit;
  41.  
  42.     #if UNITY_EDITOR
  43.     private Vector3 _tempVect_debug;
  44.     private int _count_debug;
  45.  
  46.     private Color _debug_Colour01 = Color.cyan;
  47.     private Color _debug_Colour02 = Color.magenta;
  48.  
  49.     void OnDrawGizmosSelected() {
  50.         if (EditorApplication.isPlaying) {
  51.  
  52.             if (Global_Vars._Global_GameState._current_gameState == Game_State.GameStates.StartScreen) {
  53.  
  54.                 _vect_sp = _car1.position;
  55.                 _vect_tp = _car1.position + (_car1.forward * _length);
  56.                 _vect_hit = _car2.position;
  57.  
  58.                 _angle = Check_ObjectIsInPath( _vect_sp , _vect_tp , _vect_hit , 1f );
  59.  
  60.                 Gizmos.color = Color.Lerp (Color.red , Color.white , _angle  );
  61.                 Gizmos.DrawWireCube (_car1.position, Vector3.one *  _angle  );
  62.  
  63.                 Gizmos.DrawLine ( _vect_sp , _vect_tp );
  64.                 Gizmos.DrawLine ( _vect_tp , _vect_hit );
  65.                 Gizmos.DrawLine ( _vect_sp , _vect_hit );
  66.             }
  67.         }
  68.     }
  69.     #endif
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement