Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- public class test : MonoBehaviour {
- public Transform _car1;
- public Transform _car2;
- private float _distance_start_hit;
- private float _distance_start_tp;
- private float _distance_tp_hit;
- private float _angle;
- public float _length = 1f;
- public float _oppositeLength;
- public float _oppositeAngle;
- public float Check_ObjectIsInPath( Vector3 _position_Start , Vector3 _position_Ahead , Vector3 _position_Target , float _objectRadius){
- _directionForward = _position_Start - _position_Ahead;
- _distance_ToTarget_01 = MyMath.Get_XZ_DistanceAccurate(_position_Start , _position_Target);
- _distance_angle_01 = Vector3.Angle (_position_Start - _position_Target, _directionForward);
- // opposite side length we need == sin of angle01 * length of hyp ..
- _oppositeAngle = Mathf.Sin(_distance_angle_01) * Mathf.Rad2Deg;
- _oppositeLength = _oppositeAngle * _distance_ToTarget_01;
- return _oppositeLength;
- }
- private Vector3 _vect_sp;
- private Vector3 _vect_tp;
- private Vector3 _vect_hit;
- #if UNITY_EDITOR
- private Vector3 _tempVect_debug;
- private int _count_debug;
- private Color _debug_Colour01 = Color.cyan;
- private Color _debug_Colour02 = Color.magenta;
- void OnDrawGizmosSelected() {
- if (EditorApplication.isPlaying) {
- if (Global_Vars._Global_GameState._current_gameState == Game_State.GameStates.StartScreen) {
- _vect_sp = _car1.position;
- _vect_tp = _car1.position + (_car1.forward * _length);
- _vect_hit = _car2.position;
- _angle = Check_ObjectIsInPath( _vect_sp , _vect_tp , _vect_hit , 1f );
- Gizmos.color = Color.Lerp (Color.red , Color.white , _angle );
- Gizmos.DrawWireCube (_car1.position, Vector3.one * _angle );
- Gizmos.DrawLine ( _vect_sp , _vect_tp );
- Gizmos.DrawLine ( _vect_tp , _vect_hit );
- Gizmos.DrawLine ( _vect_sp , _vect_hit );
- }
- }
- }
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement