[UE4 C++] 05-Add components

Add the following code in "SCharacter.h" to add spring arm and camera components to "SCharacter".

 Add the following code in "SCharacter.cpp"

 Regenerate the solution

 Open the Unreal Editor, and you can see the newly added camera component in the viewport. The camera is at the origin of the world coordinates and will not change position as the Character moves.

 Open "PlayerCharacter", the parameters of the spring arm component and the camera component cannot be seen in the details panel, because the components are not attached to the Character

 Back in the Rider editor, add the following two lines of code in "SCharacter.cpp". Attach the spring arm component to the root component and attach the camera component to the spring arm component

 Add the following line of code in "SCharacter.h"

Recompile, at this time, you can see that the camera and spring arm components have been mounted to Character in the viewport of UEEditor

 

Guess you like

Origin blog.csdn.net/ChaoChao66666/article/details/131664532