Trouble spawning an actor
This is more of a "I don't understands templates or function templates" post, and I'm hoping someone can help me out with understand how they work.
I am trying to spawn my actor, and I have successfully done so by doing
The issue is I want to spawn it at a certain location with a certain rotation, and this https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Actors/Spawning/ says I need to use templates for that.
I gave it a shot by literally copying the last example: (.h)
so this is my code:
I get these errors:
I followed the example exactly like it says and I can't quite figure it out.
You don't need to write the code for the template function - Unreal Engine has already provided that. You just need to call it. To call a template function, the class you want to use needs to go in the angle brackets. Like so:
This should spawn an ATower_Archer at the desired location and rotation. If you wanted to spawn another class, you'd just replace ATower_Archer with AAnother_Class.
You only need that line of code - delete the declaration and definition of SpawnActor in your own header and cpp files.
Follow this question
Once you sign in you will be able to subscribe for any updates here