using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Boom : MonoBehaviour
{
public GameObject player;
private Vector3 dp;
//private Vector3 ldp;
private Vector3 liftdp;
private Vector3 rightdp;
private float dt;
private float sin;
private float rd;
// Start is called before the first frame update
void Start()
{
rd = player.GetComponent
}
// Update is called once per frame
void Update()
{
Draw();
}
private void VectorCt()
{
dp = player.transform.position - this.transform.position;
dt = dp.magnitude;
sin = Mathf.Rad2Deg * Mathf.Asin(rd / dt);
//ldp = Quaternion.Euler(0, sin, 0) *dp.normalized * dt * Mathf.Cos(sin);
liftdp = this.transform.position + Quaternion.Euler(0, sin, 0) * dp;
rightdp = this.transform.position + Quaternion.Euler(0, -sin, 0) * dp;
}
private void CalculateTangent()
{
Vector3 playerToBoom = this.transform.position - player.transform.position;
Vector3 playerToExplpsionDirection = playerToBoom.normalized * rd;
float angle = Mathf.Acos(rd / playerToBoom.magnitude) * Mathf.Rad2Deg;
liftdp = player.transform.position + Quaternion.Euler(0, -angle , 0) * playerToExplpsionDirection;
rightdp = player.transform.position + Quaternion.Euler(0, angle, 0) * playerToExplpsionDirection;
}
private void Draw()
{
//VectorCt();
CalculateTangent();
Debug.DrawLine(this.transform.position, player.transform.position);
Debug.DrawLine(this.transform.position, liftdp,Color .blue );
Debug.DrawLine(this.transform.position, rightdp,Color .red );
}
}