I have a XML file which contains the information of every character (location,weaponID,etc).
And i write the code in the GameMode::BeginPlay() to read and parse the XML file, then spawn the character and dynamically modify the character (weapon) base on the XML.
But it doesn’t work, and I’ve already do this:
MeshComponent->SetMobility(EComponentMobility::Movable);
When i play, it shows"Access violation reading location 0x00000000000000000348"
Here is my spawn code:
UWorld* const World = GetWorld();
if (World)
{
ACharacterWithWeapon* NewActor = World->SpawnActor<ACharacterWithWeapon>(ACharacterWithWeapon::StaticClass(), SpawnLocation, FRotator(0.0f, 0.0f, 0.0f));
UStaticMesh* weaponMesh = Cast<UStaticMesh>(StaticLoadObject(UStaticMesh::StaticClass(), NULL, *weaponMeshURL.ToString()));
NewActor->MyWeapon->SetWeaponMesh(weaponMesh);
}
Thank you in advance.