public float Get_Distance_Transform() //Distance from Start to End Point { Class_Vector cl_Vector = new Class_Vector(); return(cl_Vector.Get_Distance(t_Start, t_End)); }
/// <summary> /// Set Move by Rotation /// </summary> /// <param name="f_Rotation"></param> /// <param name="f_VelocityMove"></param> public void Set_MoveRotation_XZ(float f_Rotation, float f_VelocityMove) { Class_Vector cl_Vector = new Class_Vector(); Rigidbody r_Rigidbody = GetComponent <Rigidbody>(); r_Rigidbody.AddForce( cl_Vector.Get_DegToVector_XZ( cl_Vector.Get_Exchance_Rotate_Unity(-f_Rotation), 1).normalized *f_VelocityMove); }
private Collider[] Get_Collide() { Class_Vector cl_Vector = new Class_Vector(); return (Physics.OverlapBox( transform.position, v3_Size / 2f, cl_Vector.Get_Rot_VectorToTransform(0, 0, 0), l_Tarket)); }
/// <summary> /// Check Head /// </summary> /// <returns></returns> public bool Get_CheckHead() { Class_Vector cl_Vector = new Class_Vector(); Class_Eye cs_Eye = new Class_Eye(); return(cs_Eye.Get_BoxCast_Dir_Check( transform.position, v3_HeadCast, Vector3.up, cl_Vector.Get_Rot_TransformToVector(transform.rotation), f_HeadCast, l_GroundCheck)); }
private void OnDrawGizmos() { Gizmos.color = Color.black; Class_Vector cl_Vector = new Class_Vector(); Rigid3D_Component cs_Rigid = GetComponent <Rigid3D_Component>(); Gizmos.DrawLine( transform.position, transform.position + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ(), 1f)); Gizmos.DrawWireSphere( transform.position + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ(), 1f), 0.1f); }
/// <summary> /// Set on Map Auto on Edit Mode /// </summary> private void Set_Auto() { Class_Vector cl_Vector = new Class_Vector(); if (b_isObject) { v3_Pos = cl_Vector.Get_Pos_ForIsometric(v2_Pos, f_Depth, f_Centre); } else { v3_Pos = cl_Vector.Get_Pos_ForIsometric(v2_Pos); } this.transform.position = cl_Vector.Get_Pos_PosToIsometric(v3_Pos); }
/// <summary> /// Spherecast Vec Check /// </summary> /// <param name="v3_Start"></param> /// <param name="f_Radius"></param> /// <param name="v3_End"></param> /// <param name="l_Tarket"></param> /// <param name="l_Barrier"></param> /// <returns></returns> public bool Get_SphereCast_Vec_Check_LayerMask(Vector3 v3_Start, float f_Radius, Vector3 v3_End, LayerMask l_Tarket, LayerMask l_Barrier) //Spherecast Vec Check { Class_Vector cl_Vector = new Class_Vector(); if (Get_SphereCast_Vec_Check(v3_Start, f_Radius, v3_End, cl_Vector.Get_Distance(v3_Start, v3_End), l_Barrier)) { //Hit Barrier return(false); } else if (Get_SphereCast_Vec_Check(v3_Start, f_Radius, v3_End, cl_Vector.Get_Distance(v3_Start, v3_End), l_Tarket)) { //Hit Tarket return(true); } return(false); }
/// <summary> /// Boxcast Vec Check /// </summary> /// <param name="v3_Start"></param> /// <param name="v3_Size"></param> /// <param name="v3_End"></param> /// <param name="v3_Rotation"></param> /// <param name="l_Tarket"></param> /// <param name="l_Barrier"></param> /// <returns></returns> public bool Get_BoxCast_Vec_Check_LayerMask(Vector3 v3_Start, Vector3 v3_Size, Vector3 v3_End, Vector3 v3_Rotation, LayerMask l_Tarket, LayerMask l_Barrier) //Boxcast Vec Check { Class_Vector cl_Vector = new Class_Vector(); if (Get_BoxCast_Vec_Check(v3_Start, v3_Size, v3_End, v3_Rotation, cl_Vector.Get_Distance(v3_Start, v3_End), l_Barrier)) { //Hit Barrier return(false); } else if (Get_BoxCast_Vec_Check(v3_Start, v3_Size, v3_End, v3_Rotation, cl_Vector.Get_Distance(v3_Start, v3_End), l_Tarket)) { //Hit Tarket return(true); } return(false); }
private void OnDrawGizmos() { Class_Vector cl_Vector = new Class_Vector(); if (Physics.OverlapBox( transform.position, v3_Size / 2f, cl_Vector.Get_Rot_VectorToTransform(0, 0, 0), l_Tarket).Length > 0) { Gizmos.color = Color.red; } else { Gizmos.color = Color.green; } Gizmos.DrawWireCube(transform.position, v3_Size); Gizmos.color = Color.white; //if (t_Next != null) //{ // Gizmos.DrawLine( // transform.position, // transform.position - new Vector3(transform.position.x - t_Next.transform.position.x, 0f, 0f)); // Gizmos.DrawLine( // transform.position - new Vector3(transform.position.x - t_Next.transform.position.x, 0f, 0f), // transform.position - new Vector3(transform.position.x - t_Next.transform.position.x, transform.position.y - t_Next.transform.position.y, 0f)); // Gizmos.DrawLine( // transform.position - new Vector3(transform.position.x - t_Next.transform.position.x, transform.position.y - t_Next.transform.position.y, 0f), // transform.position - new Vector3(transform.position.x - t_Next.transform.position.x, transform.position.y - t_Next.transform.position.y, transform.position.z - t_Next.transform.position.z)); //} if (t_Next != null) { Gizmos.DrawLine(transform.position, t_Next.position); } }
/// <summary> /// Set Rotation XZ /// </summary> /// <param name="f_Rotation"></param> public void Set_Rotation_XZ(float f_Rotation) { Class_Vector cl_Vector = new Class_Vector(); transform.rotation = cl_Vector.Get_Rot_VectorToTransform(new Vector3(0, f_Rotation, 0)); }
/// <summary> /// Get Rotation XZ /// </summary> /// <returns>Degree</returns> public float Get_Rotation_XZ() { Class_Vector cl_Vector = new Class_Vector(); return(cl_Vector.Get_Exchance_Rotate_Unity(cl_Vector.Get_Rot_TransformToVector(transform.rotation).y)); }
//Gizmos private void OnDrawGizmos() { if (i_Cast == 0 || t_Start == null || t_End == null) { return; } Class_Vector cl_Vector = new Class_Vector(); Class_Eye cs_Eye = new Class_Eye(); switch (i_Cast) { case 1: //LineCast Gizmos.color = Color.black; Gizmos.DrawWireSphere( t_End.position, 0.1f); //End Point is Black if (cs_Eye.Get_LineCast_Check( t_Start.position, t_End.position, l_Tarket)) { //Hit Tarket RaycastHit ray_Hit = cs_Eye.Get_LineCast_RaycastHit( t_Start.position, t_End.position, l_Tarket); Gizmos.color = Color.red; //Red is Hit Gizmos.DrawLine( t_Start.position, t_End.position); } else { Gizmos.color = Color.white; //Start Point is White, if Hit is Red Gizmos.DrawLine( t_Start.position, t_End.position); } Gizmos.DrawWireSphere(t_Start.position, f_Sphere / 2); break; case 2: //RayCast Gizmos.color = Color.black; Gizmos.DrawWireSphere( t_End.position, 0.1f); if (cs_Eye.Get_RayCast_Vec_Check( t_Start.position, t_End.position, (b_EndIsPos) ? Get_Distance_Transform() : f_Distance, l_Barrier)) { //Hit Barrier RaycastHit ray_Hit = cs_Eye.Get_RayCast_Vec_RaycastHit( t_Start.position, t_End.position, (b_EndIsPos) ? Get_Distance_Transform() : f_Distance, l_Barrier); Gizmos.color = Color.white; Gizmos.DrawRay( t_Start.position, (t_End.position - t_Start.position).normalized * ray_Hit.distance); } else if (cs_Eye.Get_RayCast_Vec_Check( t_Start.position, t_End.position, (b_EndIsPos) ? Get_Distance_Transform() : f_Distance, l_Tarket)) { //Hit Tarket RaycastHit ray_Hit = cs_Eye.Get_RayCast_Vec_RaycastHit( t_Start.position, t_End.position, (b_EndIsPos) ? Get_Distance_Transform() : f_Distance, l_Tarket); Gizmos.color = Color.red; Gizmos.DrawRay( t_Start.position, (t_End.position - t_Start.position).normalized * ray_Hit.distance); } else { Gizmos.color = Color.white; Gizmos.DrawRay( t_Start.position, (t_End.position - t_Start.position).normalized * ((b_EndIsPos) ? Get_Distance_Transform() : f_Distance)); } Gizmos.DrawWireSphere(t_Start.position, f_Sphere / 2); break; case 3: //BoxCast Gizmos.color = Color.black; Gizmos.DrawWireSphere( t_End.position, f_Sphere / 2); if (cs_Eye.Get_BoxCast_Vec_Check( t_Start.position, v3_Square, t_End.position, v3_Square_Rot, (b_EndIsPos) ? Get_Distance_Transform() : f_Distance, l_Barrier)) { //If Hit RaycastHit ray_Hit = cs_Eye.Get_BoxCast_Vec_RaycastHit( t_Start.position, v3_Square, t_End.position, v3_Square_Rot, (b_EndIsPos) ? Get_Distance_Transform() : f_Distance, l_Barrier); Gizmos.color = Color.white; Gizmos.DrawLine( t_Start.position, t_Start.position + (t_End.position - t_Start.position).normalized * ray_Hit.distance); Gizmos.DrawWireCube( t_Start.position + (t_End.position - t_Start.position).normalized * ray_Hit.distance, v3_Square); } else if (cs_Eye.Get_BoxCast_Vec_Check( t_Start.position, v3_Square, t_End.position, v3_Square_Rot, (b_EndIsPos) ? Get_Distance_Transform() : f_Distance, l_Tarket)) { //If Hit RaycastHit ray_Hit = cs_Eye.Get_BoxCast_Vec_RaycastHit( t_Start.position, v3_Square, t_End.position, v3_Square_Rot, (b_EndIsPos) ? Get_Distance_Transform() : f_Distance, l_Tarket); Gizmos.color = Color.red; Gizmos.DrawLine( t_Start.position, t_Start.position + (t_End.position - t_Start.position).normalized * ray_Hit.distance); Gizmos.DrawWireCube( t_Start.position + (t_End.position - t_Start.position).normalized * ray_Hit.distance, v3_Square); } else { Gizmos.color = Color.white; Gizmos.DrawLine( t_Start.position, t_Start.position + (t_End.position - t_Start.position).normalized * ((b_EndIsPos) ? Get_Distance_Transform() : f_Distance)); Gizmos.DrawWireCube( t_Start.position + (t_End.position - t_Start.position).normalized * f_Distance, v3_Square); } Gizmos.DrawWireCube( t_Start.position, v3_Square); break; case 4: //SphereCast Gizmos.color = Color.black; Gizmos.DrawWireSphere( t_End.position, f_Sphere / 2); if (cs_Eye.Get_SphereCast_Vec_Check( t_Start.position, f_Sphere, t_End.position, (b_EndIsPos) ? Get_Distance_Transform() : f_Distance, l_Barrier)) { //If Hit RaycastHit ray_Hit = cs_Eye.Get_SphereCast_Vec_RaycastHit( t_Start.position, f_Sphere, t_End.position, (b_EndIsPos) ? Get_Distance_Transform() : f_Distance, l_Barrier); Gizmos.color = Color.white; Gizmos.DrawLine( t_Start.position, t_Start.position + (t_End.position - t_Start.position).normalized * ray_Hit.distance); Gizmos.DrawWireSphere( t_Start.position + (t_End.position - t_Start.position).normalized * ray_Hit.distance, f_Sphere / 2); } else if (cs_Eye.Get_SphereCast_Vec_Check( t_Start.position, f_Sphere, t_End.position, (b_EndIsPos) ? Get_Distance_Transform() : f_Distance, l_Tarket)) { //If Hit RaycastHit ray_Hit = cs_Eye.Get_SphereCast_Vec_RaycastHit( t_Start.position, f_Sphere, t_End.position, (b_EndIsPos) ? Get_Distance_Transform() : f_Distance, l_Tarket); Gizmos.color = Color.red; Gizmos.DrawLine( t_Start.position, t_Start.position + (t_End.position - t_Start.position).normalized * ray_Hit.distance); Gizmos.DrawWireSphere( t_Start.position + (t_End.position - t_Start.position).normalized * ray_Hit.distance, f_Sphere / 2); } else { Gizmos.color = Color.white; Gizmos.DrawLine( t_Start.position, t_Start.position + (t_End.position - t_Start.position).normalized * ((b_EndIsPos) ? Get_Distance_Transform() : f_Distance)); Gizmos.DrawWireSphere( t_Start.position + (t_End.position - t_Start.position).normalized * ((b_EndIsPos) ? Get_Distance_Transform() : f_Distance), f_Sphere / 2); } Gizmos.DrawWireSphere( t_Start.position, f_Sphere / 2); break; } }
//Eye private RaycastHit Get_Eye(int i_CastIndex) //Get EyeCast (0: Centre; +1: Top; -1: Bot) { List <RaycastHit> l_RaycastHit = new List <RaycastHit>(); Class_Vector cl_Vector = new Class_Vector(); Class_Eye cs_Eye = new Class_Eye(); //Use this Script to use all Methode of Eye Rigid3D_Component cs_Rigid = GetComponent <Rigid3D_Component>(); //Use this Script to get "Rotation" of this Object if (!b_XZ) { //LineCast if (i_Cast == 1) { if (cs_Eye.Get_LineCast_Check( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), l_Barrier)) { //Always Hit Tarket on Line return(cs_Eye.Get_LineCast_RaycastHit( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), l_Barrier)); } } //RayCast else if (i_Cast == 2) { if (cs_Eye.Get_RayCast_Vec_Check( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier)) { //Always Hit Tarket if not have Barrier return(cs_Eye.Get_RayCast_Vec_RaycastHit( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier)); } } //BoxCast else if (i_Cast == 3) { if (cs_Eye.Get_BoxCast_Vec_Check( transform.position + v3_OffPos, v3_Square, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), new Vector3(0, 0, 0), f_Distance, l_Barrier)) { //Always Hit Tarket if not have Barrier return(cs_Eye.Get_BoxCast_Vec_RaycastHit( transform.position + v3_OffPos, v3_Square, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), new Vector3(0, 0, 0), f_Distance, l_Barrier)); } } //SphereCast else if (i_Cast == 4) { if (cs_Eye.Get_SphereCast_Vec_Check( transform.position + v3_OffPos, f_Sphere, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier)) { //Always Hit Tarket if not have Barrier return(cs_Eye.Get_SphereCast_Vec_RaycastHit( transform.position + v3_OffPos, f_Sphere, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier)); } } } else if (b_XZ) { //LineCast if (i_Cast == 1) { if (cs_Eye.Get_LineCast_Check( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), l_Barrier)) { //Always Hit Tarket if not have Barrier return(cs_Eye.Get_LineCast_RaycastHit( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), l_Barrier)); } } //RayCast else if (i_Cast == 2) { if (cs_Eye.Get_RayCast_Vec_Check( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier)) { //Always Hit Tarket if not have Barrier return(cs_Eye.Get_RayCast_Vec_RaycastHit( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier)); } } //BoxCast else if (i_Cast == 3) { if (cs_Eye.Get_BoxCast_Vec_Check( transform.position + v3_OffPos, v3_Square, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), new Vector3(0, 0, 0), f_Distance, l_Barrier)) { //Always Hit Tarket if not have Barrier return(cs_Eye.Get_BoxCast_Vec_RaycastHit( transform.position + v3_OffPos, v3_Square, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), new Vector3(0, 0, 0), f_Distance, l_Barrier)); } } //SphereCast else if (i_Cast == 4) { if (cs_Eye.Get_SphereCast_Vec_Check( transform.position + v3_OffPos, f_Sphere, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier)) { //Always Hit Tarket if not have Barrier return(cs_Eye.Get_SphereCast_Vec_RaycastHit( transform.position + v3_OffPos, f_Sphere, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier)); } } } return(new RaycastHit()); }
//=== Gizmos private void Set_Gizmos(int i_CastIndex) { Class_Vector cl_Vector = new Class_Vector(); Class_Eye cs_Eye = new Class_Eye(); Rigid3D_Component cs_Rigid = GetComponent <Rigid3D_Component>(); if (!b_XZ) { //LineCast if (i_Cast == 1) { if (cs_Eye.Get_LineCast_Check( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), l_Barrier)) { //Always Hit Tarket if not have Barrier RaycastHit ray_Hit = cs_Eye.Get_LineCast_RaycastHit( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), l_Barrier); Gizmos.color = Color.red; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance)); } else { Gizmos.color = Color.green; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance)); } } //RayCast else if (i_Cast == 2) { if (cs_Eye.Get_RayCast_Vec_Check( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier)) { //Always Hit Tarket if not have Barrier RaycastHit ray_Hit = cs_Eye.Get_RayCast_Vec_RaycastHit( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier); Gizmos.color = Color.red; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, ray_Hit.distance)); } else { Gizmos.color = Color.green; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance)); } } //BoxCast else if (i_Cast == 3) { if (cs_Eye.Get_BoxCast_Vec_Check( transform.position + v3_OffPos, v3_Square, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), new Vector3(0, 0, 0), f_Distance, l_Barrier)) { //Always Hit Tarket if not have Barrier RaycastHit ray_Hit = cs_Eye.Get_BoxCast_Vec_RaycastHit( transform.position + v3_OffPos, v3_Square, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), new Vector3(0, 0, 0), f_Distance, l_Barrier); Gizmos.color = Color.red; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, ray_Hit.distance)); Gizmos.DrawWireCube( transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, ray_Hit.distance), v3_Square); } else { Gizmos.color = Color.green; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance)); Gizmos.DrawWireCube( transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), v3_Square); } } //SphereCast else if (i_Cast == 4) { if (cs_Eye.Get_SphereCast_Vec_Check( transform.position + v3_OffPos, f_Sphere, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier)) { //Always Hit Tarket if not have Barrier RaycastHit ray_Hit = cs_Eye.Get_SphereCast_Vec_RaycastHit( transform.position + v3_OffPos, f_Sphere, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier); Gizmos.color = Color.red; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, ray_Hit.distance)); Gizmos.DrawWireSphere( transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, ray_Hit.distance), f_Sphere / 2); } else { Gizmos.color = Color.green; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance)); Gizmos.DrawWireSphere( transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XY(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Sphere / 2); } } } else if (b_XZ) { //LineCast if (i_Cast == 1) { if (cs_Eye.Get_LineCast_Check( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), l_Barrier)) { //Always Hit Tarket if not have Barrier RaycastHit ray_Hit = cs_Eye.Get_LineCast_RaycastHit( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), l_Barrier); Gizmos.color = Color.red; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance)); } else { Gizmos.color = Color.green; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance)); } } //RayCast else if (i_Cast == 2) { if (cs_Eye.Get_RayCast_Vec_Check( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier)) { //Always Hit Tarket if not have Barrier RaycastHit ray_Hit = cs_Eye.Get_RayCast_Vec_RaycastHit( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier); Gizmos.color = Color.red; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, ray_Hit.distance)); } else { Gizmos.color = Color.green; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance)); } } //BoxCast else if (i_Cast == 3) { if (cs_Eye.Get_BoxCast_Vec_Check( transform.position + v3_OffPos, v3_Square, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), new Vector3(0, 0, 0), f_Distance, l_Barrier)) { //Always Hit Tarket if not have Barrier RaycastHit ray_Hit = cs_Eye.Get_BoxCast_Vec_RaycastHit( transform.position + v3_OffPos, v3_Square, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), new Vector3(0, 0, 0), f_Distance, l_Barrier); Gizmos.color = Color.red; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, ray_Hit.distance)); Gizmos.DrawWireCube( transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, ray_Hit.distance), v3_Square); } else { Gizmos.color = Color.green; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance)); Gizmos.DrawWireCube( transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), v3_Square); } } //SphereCast else if (i_Cast == 4) { if (cs_Eye.Get_SphereCast_Vec_Check( transform.position + v3_OffPos, f_Sphere, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier)) { //Always Hit Tarket if not have Barrier RaycastHit ray_Hit = cs_Eye.Get_SphereCast_Vec_RaycastHit( transform.position + v3_OffPos, f_Sphere, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Distance, l_Barrier); Gizmos.color = Color.red; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, ray_Hit.distance)); Gizmos.DrawWireSphere( transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, ray_Hit.distance), f_Sphere / 2); } else { Gizmos.color = Color.green; Gizmos.DrawLine( transform.position + v3_OffPos, transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance)); Gizmos.DrawWireSphere( transform.position + v3_OffPos + cl_Vector.Get_DegToVector_XZ(-cs_Rigid.Get_Rotation_XZ() + i_CastIndex * f_OffFan, f_Distance), f_Sphere / 2); } } } }
//private void Update() //{ // //Class_Vector cl_Vector = new Class_Vector(); // //if (t_Next != null) // //{ // // float f_Distance = Vector3.Distance(transform.position, t_Next.position); // // float f_Deg = cl_Vector.Get_Rot_TransformToVector(transform.rotation).y; // // Vector3 v3_DirStart = cl_Vector.Get_Dir_XZ(transform.position, transform.position + cl_Vector.Get_DegToVector_XZ(-f_Deg, f_Distance)); // // Vector3 v3_DirEnd = cl_Vector.Get_Dir_XZ(transform.position, transform.position + cl_Vector.Get_Dir_XZ(transform.position, t_Next.position) * f_Distance); // // Debug.Log(cl_Vector.Get_DirToDeg_XZ(v3_DirStart, v3_DirEnd)); // //} // //if (t_Next != null) // //{ // // Debug.Log(cl_Vector.Get_DirToDeg_XZ_RotateFromTransform(this.transform, t_Next.transform)); // //} //} public float Get_OffsetRotate() { Class_Vector cl_Vector = new Class_Vector(); return(cl_Vector.Get_DirToDeg_XZ_RotateFromTransform(this.transform, t_Next.transform)); }