Calling Functions in C++
We are going to learn how to call function in C++ and bring a cube into the level when we start playing.
- Functions from Blueprint to C++
In C++ we say the function name first and then the vector we place in parentheses as input called arguments.
Now if we wanted to just set the location of the vector we could say SetActorLocation(FVector(1,2,3))
So in our cpp file we are going to set our Actor’s location.
We are going back to the Editor and add a cube to our movingplatform actor. If we click play and select eject we can go to our moving platforms, location and see the transform is where we have it in our code. When we move over to our moving platform we can see our cube at 1,2,3.
We are now going to replace FVector with a variable, update MyVector, and bring the cube closer to the player.
In our cpp file we are going to change out our SetActorLocation(var) to (MyVector) and back in our editor copy our pawn start location and paste them to our MyVector in our header file.
We have now spawned our cube in-front of our player using C++.