Hi,
i'm new to program in C++, but not new in programming at all (C on micro-controllers for years).
But now i ran into a problem and i don't understand the cause of this.
My code is mostly from the First Person Shooter C++ Tutorial. I only left out the First-Person Mesh and all Animation stuff.
I tried now to add a HUD. I set up a public variable for my AStdCharacter inside of AStdCharacter.h
I'm initializing it with 100.
Inside of the PlayerHUD.cpp, i added
This worked for a time - then i tried to spawn 2 Players (Inside of the Editor, with "Play"). The game crashed (Access violation - code c0000005 (first/second chance not available))
As soon as i want to spawn a second player the game crashes. If i only spawn 1 Player, everything is fine. What am i doing wrong? I'm sure i missed something essential out, but i don't know what.
i'm new to program in C++, but not new in programming at all (C on micro-controllers for years).
But now i ran into a problem and i don't understand the cause of this.
My code is mostly from the First Person Shooter C++ Tutorial. I only left out the First-Person Mesh and all Animation stuff.
I tried now to add a HUD. I set up a public variable for my AStdCharacter inside of AStdCharacter.h
Code:
//Current Health of the Player UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Health) float fHealth;
Inside of the PlayerHUD.cpp, i added
Code:
const float fLower = Canvas->ClipY * 0.95f; const float fLeft = Canvas->ClipX * 0.025f; AStdCharacter* MyPawn = Cast<AStdCharacter>(GetOwningPawn()); float health = MyPawn->fHealth; DrawText(FString::Printf(TEXT("Health %f"), health), FColor::Black, fLeft, fLower, HUDFont, 2.0f, false);
As soon as i want to spawn a second player the game crashes. If i only spawn 1 Player, everything is fine. What am i doing wrong? I'm sure i missed something essential out, but i don't know what.
Comment