Hi, i’m just wondering how you can give a class a transform. I know i can use blueprint to give the object a transform with the scene component but i would like to be able to add a root component in C++ that can give the class a transform.
I have been looking around and found the USceneComponent but i’m having trouble getting one into my code, anyone have an example for me to try?
The AActor class has a RootComponent property. If you look at a class such as AAmbientSound you can see how a SceneComponent subclass is instantiated and then assigned to the RootComponent pointer. This gives your AActor its position in the world.
You can use the SceneComponent directly. As it says in its header: " A SceneComponent has a transform and supports attachment, but has no rendering or collision capabilities. Useful as a ‘dummy’ component in the hierarchy to offset others."
I did a quick look and an even more relevant example to your case is in AMatineeActor. Here are the relevant lines: