How to swap out the visual mesh component of a pawn at run-time.
I am attempting to replace the visible component of a pawn with a different component at runtime (in my case a
I set up my pawn like this in its constructor (where
However, this leads to all sorts of bad results. I've tried various hand-wavey iterations of this:
How do I do this properly?
I'm super new to the Unreal SDK, as in yesterday morning I was doing a crash course through tutorials and docs to try and get this done. I eventually arrived at the above. I have a feeling that my mistake here is some misunderstanding of life-cycles, replication, or maybe e.g. reference counting due to say player input on the pawn or something:
Update: The player input theory is eliminated. I tried the exact same thing as above but with a regular actor instead of a pawn (camera eliminated, no player input, just
I'm not sure which direction to head in next.
So after a lot of hunting I stumbled on somebody else's code, and it turns out the problem is in the component creation.
I changed it to:
And it seems to be working, aside from the component initially created in the constructor sticking around in the object tree the whole time (which seems to be related to "default" values, but it doesn't seem to be having any bad effects, so...).
I'm not sure if I just missed this in the documentation, or if Epic felt like only developers who hunted the vast plains of the internet for it were worthy of the knowledge. The tutorials could be improved by mentioning clearly that the frequently used SetupAttachment isn't useful for runtime components.
answered Feb 12 '17 at 08:46 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here