Download

how can i control object with c++

hi , i have a static mesh object called “capsule1” (static mesh) in editor and i want to control this with c++ . how can i attach c++ code to this object ? File -> Add code to project -> ??? Ty

Hi,

go check tutorials before trying to do something without any knowledge, thank you for understanding.

Regards.

hi , i read tutorials , but tutorials like do that .

1.)File -> Add code to project -> actor
2.) and creating object TSubobjectPtr<USphereComponent> Sphere1; Sphere1 = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT(“Sphere1”));

this is ok , but if my object created before in the wiew port and i want to add c++ code later , how can do this. what type of this ??? Gamemode?

Then you have to delete this actor, create your own actor with your code and spawn it. You can’t add C++ code to existing spawned objects.

If the actor is blueprint based, you can reparent it to another actor class via editor.

Ty m8 , then can i do find object and control him with c++ for existing spawned object?

Yeah, you actually can find your object via actor iterators, https://wiki.unrealengine.com/Iterators:Object%26_Actor_Iterators,_Optional_Class_Scope_For_Faster_Search

nice :slight_smile: ty for your link . its helped me to much :wink: