Download

How to instantiate an actor C++

I have tried this:


	static ABasePlayer* Instantiate(const UWorld* world)
	{
		UClass* player = ABasePlayer::StaticClass();
		return world->SpawnActor<ABasePlayer>(player, FVector(0.0f, 0.f, 0.f), FRotator(0.0f, 0.f, 0.f), FActorSpawnParameters());
	}

and this:


	static ABasePlayer* Instantiate(const UWorld* world)
	{
		return world->SpawnActor<ABasePlayer>(ABasePlayer::StaticClass(), FVector(0.0f, 0.f, 0.f), FRotator(0.0f, 0.f, 0.f), FActorSpawnParameters());
	}

and this:


	static ABasePlayer* Instantiate(const UWorld* world)
	{
		return world->SpawnActor<ABasePlayer>(ABasePlayer::StaticClass());
	}

and lots of other stuff too.

The compiler says:



Error	1	error C2663: 'UWorld::SpawnActor' : 2 overloads have no legal conversion for 'this' pointer	E:\Documents\Unreal Projects\TemplatePlatformer\Source\TemplatePlatformer\Public\BasePlayer.h	37	1	TemplatePlatformer
Error	2	error C2663: 'UWorld::SpawnActor' : 2 overloads have no legal conversion for 'this' pointere:\documents\unreal projects	emplateplatformer\source	emplateplatformer\public\BasePlayer.h(37) : error C2663: 'UWorld::SpawnActor' : 2 overloads have no legal conversion for 'this' pointer	e:\documents\unreal projects	emplateplatformer\source	emplateplatformer\public\BasePlayer.h	37	1	TemplatePlatformer

I have followed:

https://answers.unrealengine.com/questions/154921/how-can-i-instantiate-an-actor-before-spawning-in.html
https://answers.unrealengine.com/questions/43292/how-do-you-instantiate-a-notplacable-actor.html
https://answers.unrealengine.com/questions/36640/how-to-initialize-an-instance-of-an-object.html

I am running:

Unreal Engine 4.6

Have you tried to remove const from world parameter?

ddvlost… You are a sexy beast… I hope you realise that… I literally ignored the **** out of that const for the entire time… Oh the embarassment, the shame… woe is me, woe… is… me. Thanks browskie muchosovsky!