I want to dynamically allocate a third-party class instance inside an Actor but using operator new results to some problems. As a result, can you give me some directions and possible ideas on how to instantiate a third-party class inside an actor in Unreal Engine?
Are you sure it was supposed to be zero initialized? There are cases in C++ where variables are supposed to be uninitialized, and so will contain whatever initial value of whatever was in their allocated memory previously (like a random large number). Can you show the code where you are using the new operator ?
First of all, thank you for the interest in the topic.
You can see this more detailed post for the problem I encountered. The third-party library is mujoco (you can find the code here). mjCModel structure can be found in this folder in user_model.h file but the problem is encountered when I use AddGeom() where inside the code there is a new mjCGeom and this is the structure that cannot be initialized correctly. I have checked what you are saying and normally in construction the variables have some default values so not initialized variables is not the case.
Yes, that’s right but can you think of any reason for the bug? Or any possible solution to try?
Yes, try stepping through this code with the debugger on both the working version and non-working version and then compare the behaviour to see what is going on. Specifically locate the point at which their behaviours diverge.