Announcement

Collapse
No announcement yet.

How to instantiate an actor C++

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to instantiate an actor C++

    I have tried this:


    Code:
    	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:


    Code:
    	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:

    Code:
    	static ABasePlayer* Instantiate(const UWorld* world)
    	{
    		return world->SpawnActor<ABasePlayer>(ABasePlayer::StaticClass());
    	}
    and lots of other stuff too.

    The compiler says:
    Code:
    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\templateplatformer\source\templateplatformer\public\BasePlayer.h(37) : 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
    I have followed:

    https://answers.unrealengine.com/que...awning-in.html
    https://answers.unrealengine.com/que...ble-actor.html
    https://answers.unrealengine.com/que...an-object.html

    I am running:

    Unreal Engine 4.6
    Last edited by jimmyt1988; 01-12-2015, 09:20 PM.

    #2
    Have you tried to remove const from world parameter?

    Comment


      #3
      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!

      Comment

      Working...
      X