So basically, in Unity I have made a little game, but in Unity you must script many things that are already done for us in UE4 (like playing an array of sounds in a random order) and I’m lazy ^^
So, I’d like to port my game over, but I have a problem at the very start, with my player…
In Unity, Camera and Player are individual objects (else camera would rotate with player…) and the camera has a script to smoothly follow the player. The player has a script to always look at the mouse cursor and move independent of rotation.
-create a new actor as a camera actor.
-attach camera component to it
-place it in your level
-use get all actors of class to find the camera actor in level, either in level blueprint or inside the player blueprint or a manager actor you wrote and then handle the movement as wanted
I already tried placing a camera down, but it would just use the one from the character blueprint (or if there is none, it would create one and attach it to the character) instead of using the one I put down…
How can I set up which camera to use in the Blueprint?
i recreated the camera system in the linked Unity video inside of a test project. For starters i began with the shooter template and change its camera setup. If you used a different template or no template at all, the method may be a little different than what i have done but you should still be able to take something from this. I basically unparented the camera from the mesh to that it will move independently from the pawn rotation. The way its setup by default the pawn yaw rotation is rotation is being inherited by the mesh and the camera. We want the mesh to be still inherit the yaw but we want the camera to have no rotation. Once we unparent the camera, it will not rotate but neither will the mesh so we have to manually make the mesh rotate according to mouse inputs.
I created a function (Rot) to handle the making of the rotation. Inside the function you will need to add one float input (named right) and a rotation output. Now add getter reference for the mesh, get world rotation and then break it. drag out the yaw and then add a float addition node and add the yaw and the right together. now add a make rot node and connect the addition node to the yaw input then connect the make rot to the rotation output of the function. As you may notice i have also left the ablility to add up and down rotation to the mesh aswell but in the unity video the pawn didnt seem to be looking up and down so i have left it disconnected. Now add the call function node for your function in the event graph. Connect the Turn float output from the event to the right input on the function. Drag off the rotation pin and create a set world rotation node. Then connect the call function node after the turn event. After that it should work but if it doesnt or if this very long explanation isn’t clear enough (11:30pm where i am) then please let me know what your having trouble with and i will try my best to help. Good Luck!