FVector MyVector = FVector(1.2f, 3.4f, 6.1f);why it doesn't work?

I am a cpp developer and I am learning the unreal engine by your course but there is something occupied my mind and that is why we can’t initialize the fvector liuke this:FVector MyVector(1, 2, 3). Because in cpp we can call a constructor of a struct like this but,In unreal we have to call like this:FVector MyVector = FVector(1.2f, 3.4f, 6.1f);.why?

Hi,
I suspect the reason is FVector is actually created from a templated struct and not just a regular struct and that the FVector itself expects doubles. When you specify int values it doesn’t know what to do.

The actual type is complex and as a result, the constructor doesn’t work as expected. Note that the screenshpt below is 2 levels down.
This is why you normally see it being done with FVector(1.2, 2.2, 3.4) instead

1 Like

thank you so much man.even the AI couldn’t help me in this subject.