Hello fellow Unity experts, I am fairly novice in handling rotations.
My 3D object initially has -35 degrees in X-axis, since I like how it looks from this isometric-ish angle. Then I attempted to rotate around the Y-axis using Rotate(0, angle, 0) to make it face towards a target. If you look at the embedded video, you can see that Rotate(0, 45, 0) does not look aligned with -45 degrees Z-axis for a 2D collider (not to be surprised).
From my observation, the rotation required is approximately:
Rotate(0, 30, 0) -> -15 degrees Z-axis
Rotate(0, 65, 0) -> -45 degrees Z-axis
Rotate(0, ~77, 0) -> -60 degrees Z-axis
Rotate(0, 90, 0) -> -90 degrees Z-axis
For the math wizards out there
Is it possible to get this angle in such a way that can achieve my desired visual effect?
I appreciate any help I can get, thanks in advance.
https://streamable.com/odbmt2
2 Answers
2
I know that my solution is not as efficient as a single Box Collider but what about enabling Particle Collision?

There are quite a few settings such as Collision Quality and Max Collision Shapes which allow you to optimize the effect.
Then you just need to add this method to the Particle GameObject:
private void OnParticleCollision(GameObject collision)
{
if (collision.CompareTag(EnemyTag))
{
collision.transform.GetComponent<HealthInterface>().TakeDamage(20);
}
}
Hi Patrick, thanks for your reply, my question was more towards getting the right rotation to use for my VFX 3D object? The context is that my player is trying to use this spell on a target. Here’s my existing code:
// Calculate the direction from this player to the target
Vector2 directionToTarget =
target - new Vector2(transform.position.x, transform.position.y);
// Calculate the angle needed to rotate around the y-axis to face the target
float angle = Mathf.Atan2(directionToTarget.y, directionToTarget.x) * Mathf.Rad2Deg;
transform.Rotate(0, angle, 0);
But as you can see, rotating the y-axis by 45 degrees doesn’t really look like 45 degrees when viewed from a 2D top-down view.
Ok, why can't you just put an emty gameobject facing the correct rotation inside of the particle system? You will get the direction using ThatTransform.forward
– Patrickmol