Announcement

Collapse
No announcement yet.

The character disappears on the client when the host does not see it?

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

    The character disappears on the client when the host does not see it?

    If I drag a character from the project, and start the game already with him, then he is always visible. But if I create a character in runtime, then such a bug occurs. Anybody can help me with it?


    Click image for larger version  Name:	3.jpg Views:	2 Size:	168.7 KB ID:	1742951

    Click image for larger version  Name:	4.jpg Views:	2 Size:	139.2 KB ID:	1742952

    Code:
    ABaseEntity* AEntities::Spawn(const FString& cs, const FVector& vector, ETeam_t team, UWorld* world, AActor* net_owner)
    {
        const FString fullPath = "Blueprint'/Game/Units/" + cs + "." + cs + "_C'";
        const TSubclassOf<AActor> SpawnActor = Cast<UClass>(StaticLoadObject(UObject::StaticClass(), NULL, TCHAR_TO_WCHAR(*fullPath), NULL, ELoadFlags::LOAD_Verify, NULL, true));
    
        FActorSpawnParameters SpawnParams;
        SpawnParams.Owner = net_owner;
        SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
    
        ABaseEntity* actor = world->SpawnActor<ABaseEntity>(SpawnActor, vector, FRotator::ZeroRotator, SpawnParams);
    
        actor->SetTeam((int)team);
        actor->TeleportTo(vector, FRotator::ZeroRotator);
        actor->RegisterComponents();
        actor->SpawnDefaultController();
    
        return actor;
    }
    Last edited by Freeman1852; 04-08-2020, 11:41 AM.

    #2
    Your explanation is teling me nothing.
    For networking, if a Actor should be properly visible to server and Client, ist must be spawned on the server.
    NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | RuntimeMeshImportExport | DebugWidget | SteamWorkshopAccessor

    Comment

    Working...
    X