OK, I’m now begging for help. This has held me up for weeks and I have deadlines I’m gaping at not reaching if I can’t jump what I imagine is a simple hurdle for anyone else out there.
I have a MyCharacter actor (the default) and an actor/pawn set up called an ‘Engineer’.
I have successfully managed to possess the engineer by using Event Actor Begin Overlap running from inside the MyCharacter blueprint:
So now I’m stuck inside the engineer. I’ve tried Timers in various ways to call functions in the engineer to possess the original MyCharacter, but what I’d prefer to do is delete the old MyCharacter object on first possession and then have the Engineer ‘die’ after 30 seconds and then a new version of the MyCharacter spawn in it’s place with control given to it. I can then add in scoring and extras afterwards.
It’s really just the mechanics of: How do I get out of the Engineer into a newly spawned version of MyCharacter?
Just spawn MyCharacter and store reference to spawned actor, then when you want to possess it - cast actor to MyCharacter and call possess on resulting variable.
What you’re saying makes sense, and it’s something I’ve tried - but I just can’t make it happen via blueprints…
Firstly, how do I spawn the MyCharacter? It spawns on starting the game, but outside of that I never have reference to it.
I tried SpawnAIFromClass in the construction script so I could build a variable as a reference, as that seems to be the only operation available using spawn that comes close…so I ended up with this, which I know won’t work…
I also attempted to put the setup for destroying the actor into the Engineer, but that just leaves me with an unpossessed stuck view of the horizon. Nothing I put after destroying the Engineer does anything.
I have an alternative trick I could use, that would be to attach the MyCharacter to the Engineer - which worked once, but upon attempting to destroy the Engineer after 10 seconds it always destroyed the MyCharacter part…so I gave up on that approach.
Thank you for the assist so far…if you can just please help me get my head wrapped around this one thing, so much would fall into place.
It does depend significantly on what you are attempting to do. What I’ve found works best much of the time is to cast to the 2nd pawn, possess it, and then tell the default pawn to go hidden from view (and possibly move it to a spot somewhere completely out of the way so nothing can bump into it).
To reverse the flow, just do exactly what you already did, move the default back into location, turn off hide, then cast the possession to it the same way you did the first, then destroy or hide the other, or have an AI possess it…whatever you’re actually trying to do…
It does depend significantly on what you are attempting to do. What I’ve found works best much of the time is to cast to the 2nd pawn, possess it, and then tell the default pawn to go hidden from view (and possibly move it to a spot somewhere completely out of the way so nothing can bump into it).
To reverse the flow, just do exactly what you already did, move the default back into location, turn off hide, then cast the possession to it the same way you did the first, then destroy or hide the other, or have an AI possess it…whatever you’re actually trying to do…