Why does this Blueprint segment behave differently to this supposedly equivalent Unity C# code?

My Blueprint segment:

My Unity C# code:

Below is a screenshot of an explanation of how Vector3.Angle() works in Unity, for easy reference.

Hi guys, I’m a game dev student, trying to port a project from Unity to Unreal.

I’ve worked around this specific issue in a different way, but for the sake of knowledge and writing up my work for my uni professors, can anyone help me to figure out why these implementations are different?

I wrote the C# code myself, and it works exactly as I want it to, and as described in the comment on the screenshot, so I tried to translate it directly into Unreal Blueprint, but unfortunately it wasn’t working at all, and I wasn’t able to figure out why.

Any ideas?

Thank you everyone.

Hi!

Your logic seems to be correct. Are you sure that you pass correct vectors to it?

I’ve tried to replicate your BP and made an Actor to test it.

I have an Actor BP_AngleTest that has two arrows. It calculates angle between them every tick using your BP logic, and prints result to the screen.


I’ve tested it by moving second arrow, and results seems correct:



So I think that vectors that you pass to the formula are wrong.