SetActorLocation. About using a variable or doing it manually

Hi mates and team.

In Unreal 5.0 C++ Developer: Learn C++ and Make Video Games course, lecture Calling Functions in C++, there is an exercise about moving a cube (time 4:40).

If i put the variable arguments manually it doesnt work:

SetActorLocation(FVector (13826.000000,3390.000000,4055.000000));
and the cube doesnt even appear.

But if I use the previously declared FVector in .h file and initialize it from the UE5 editor it works perfectly:

//.h file
FVector Myvector = FVector(1, 2 ,3);

//.cpp file


Whats the point here?

ok, mates…

It looks like is all about collisions. I copied and pasted de position of the character, literally. Now i moved 100 units forward the cube location and it summons fine.

Anyway, my question remains: Why using a variable it doesnt work but using the UE5 editor, even using the same values, it summons?


The values you’re showing aren’t the same.

 13826.0,  3390.0, 4055.0 # what you said isn't working
-13826.0, -3390.0, 4055.0 # what you said is, X & Y are negative

My apologies, it is just a typo.

The coord of the capture is the right.

Anyway, the point is the caracter (a simple cube) does not summon in one way (using code) but in the other one (using the UE5 editor). I dont really know why but i think is something related to code execution order in some way.

It’s the same and I just tested it and it works as expected both ways. Are you able to showcase what you’re getting?

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms