Yea that is just the component or is it the object class. ?
The component is not the whole class. I think this is the component.
And you are using the component inside the GetWrold() line to use as object key class to access the < A Aclass > and that is wrong, it will return null.
laterā¦something like
ItemGroupRef->AttachToComponent Get some other function you need to grab whatever(), FAttachmentTransformRules:: blah blah blah and so on.
And there for you attached the itemgroup object component to your local component on the relative scale you set in the other page and now you transform to world since the relative values come from the other cpp page ?
I hope you are not making one of those violent 3d Shooter game where you just stand with your gun and shoot people people are stuck and synapsing on that, on 3d shooter.
Good luck ditching BP and going C++. I donāt like BP I call them cosmetics and only use them only when I have to like to decorate things
The wrong part is ditch BP completley, start with a static mesh component that has a scene component that has a mesh attached to the static mesh.
Start from the very start.
This time actually add the root component.
Root = CreateDefaultSubobject< USceneComponent >(āUSceneComponentā);
Then you can attach the static component to the root uscene component.
Step 2 get world to import with Tsubclassof from the other cpp the object you wish to spawn and create a component for it attach component from the other cpp to your component.
Step 3 Use get possition to get the relative possition of the imported object
I understand there is no need for the mesh because it comes from the other CPP imported class so you may want to skip this and only implement it in the other cpp page, because you need it there loaded on the component, the static mesh that is because you will import the component with it.
just comes back and tried Your solution without changing the SceneComponent and now the static mesh is not returning nullprt, the groupitem actor is spawned in the level but the static meshes it hold are empty and no item is attached to them.
now when I run this function in beginplay to spawn items it crash the engine.
but if i run this function in the onconstructor everythng works fine and the meshes are not empty.
is it okay to run the function in onconstructor?
No, itās not a good practice to run it on the constructor. But it should have no problem if you donāt overload the constructor so donāt add other functions there because itās not suppose to take many things, maybe you can post the beginplay crash error.
when i run this function under OnConstruction(const FTransform& Transform) everything just works fine, i donāt know why its not working on beginplay function
the C++ beginplay is not working like you expect to be as blueprint beginplay, the C++ onconstruction is the blueprint constructor.
learn more about their differences ā¦ and remember one thing if you are spawning actors at runtime you should spawn them on constructor and on beginplay set their meshes. if you are doing these all stuff in one function then your function will not work on beginplay from bp side.
`OnConstruction(const FTransform& Transform) is not the main constructor function, so you can run things there without problems.
the constructor is simply denoted by the name of the class.
AMyClass::AMyClass()
{ constructor content}
The other function uses the construct and transform, it uses the constructor to automate your construct you can put everything inside of it, itās not a problem.
You need to set up a blueprint after your class to make the getworld() work.
The variables are extended in the blueprint, and on the menu you got the spawn options from your parent class. Itās just an empty blueprint made after the class to spawn the objects you want and it will represent your class, rest nodes and so on you donāt need them. You do need a representative for your class to spawn things around and replicate spawns.
Sure anytime, for a beginer, life is hard as a beginer in C++.
Takes 15 to 20 years to become expert god like in C++
Takes about serveral years just to become an advenced c++ user.
So it works on const and trans function, because itās suppose to work there.
Maybe if you tweek some things on begin play it will work there as well.
I have mine on begin play and it works, but I cannot post the whole code here, itās just unfair.
So what I get from you is that you have not created a blueprint based on your class, that might be your problem. So you just used the meta tag instead to expose access to blueprints.