public void SetTargetWithAngle(Vector3 point, float angle) { currentRadian = angle * Mathf.Deg2Rad; targetPoint = point; //GizmosHelper.DrawBox(point, Vector3.one * 0.2f, Color.yellow); Vector3 direction = point - firePoint.position; //if (Vector3.Angle(direction, transform.forward) > 10) //{ // // Haven't face the right direction. // projectileArc.gameObject.SetActive(false); // return; //} //else //{ // projectileArc.gameObject.SetActive(true); //} float yOffset = direction.y; direction = Math3d.ProjectVectorOnPlane(Vector3.up, direction); float distance = direction.magnitude; currentSpeed = ProjectileMath.CalculateLaunchSpeed(distance, yOffset, Physics.gravity.magnitude, angle * Mathf.Deg2Rad); projectileArc.UpdateArc(currentSpeed, distance, Physics.gravity.magnitude, currentRadian, direction, true); SetThrowPoint(direction, currentRadian * Mathf.Rad2Deg); }
public void SetTargetWithAngle(Vector3 point, float angle) { currentAngle = angle; Vector3 direction = point - firePoint.position; float yOffset = -direction.y; direction = Math3d.ProjectVectorOnPlane(Vector3.up, direction); float distance = direction.magnitude; currentSpeed = ProjectileMath.LaunchSpeed(distance, yOffset, Physics.gravity.magnitude, angle * Mathf.Deg2Rad); projectileArc.UpdateArc(currentSpeed, distance, Physics.gravity.magnitude, currentAngle * Mathf.Deg2Rad, direction, true); SetTurret(direction, currentAngle); }