I am following along with the 3rd person power up game with c++ tutorial. I believe I’ve done everything in the video correctly. After I key mapped C to pick up the batteries, when I try to pick up the batteries using c, the game closes on me. The unreal engine directly exit It does give me this information:
We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.
Sorry, it’s been awhile. I have been busy with college and working. Here is the source file’s code.
// Fill out your copyright notice in the Description page of Project Settings.
#include "BatteryCollector.h"
#include "Pickup.h"
// Sets default values
APickup::APickup()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
//All pickups start active
bIsActive = true;
//Create the static mesh component
PickupMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PickupMesh"));
RootComponent = PickupMesh;
}
// Called when the game starts or when spawned
void APickup::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APickup::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
// Returns active state
bool APickup::IsActive()
{
return bIsActive;
}
// Changes active state
void APickup::SetActive(bool NewPickupState)
{
bIsActive = NewPickupState;
}
void APickup::WasCollected_Implementation()
{
//Log a debug message
FString PickupDebugString = GetName();
UE_LOG(LogClass, Log, TEXT("You have collected %s"), *PickupDebugString);
}
The callstack mentions the SetActive function which appears to be setup correctly. I’m curious if the information passed to it from ABatteryCollectorCharacter::CollectPickups() is bad. Can you post the CollectPickups() function as well as the log files from the crash? I ran through the battery collector tutorial and did not receive a crash so it may be helpful if you could send a zip of your project as well.
void ABatteryCollectorCharacter::CollectPickups()
{
// Get all overlapping Actors and store them in an array
TArray<AActor*>CollectedActors;
CollectionSphere->GetOverlappingActors(CollectedActors);
// For each Actor we collected
for (int32 iCollected = 0; iCollected < CollectedActors.Num(); ++iCollected)
{
// Cast the actor to APickup
APickup* const TestPickup = Cast < APickup >(CollectedActors[iCollected]);
// If the cast is succesful and the pickup is valid and active.
if (TestPickup && !TestPickup->IsPendingKill() && TestPickup->IsActive())
// call the pickup's WasCollected function
TestPickup->WasCollected();
//Deactivate the pickup
TestPickup->SetActive(false);
}
}
How do I export the entire project? I went to file → export all. But it’s saying the file type is not permitted, when I try and export the project on ue4 answerhub.
I went to “packaged projects” and from there to zipping up the project. But when I try to upload the zipped project which I saved to my desktop it says,“no such upload.”
If you are attempting to upload the project here on AnswerHub, please try again to attach the project. Sometimes AnswerHub does not register when trying to add images or other attachments to a post. Additionally, can you let me know if you’re still getting a crash if you run through the tutorial videos in the latest engine version (4.12.2)?
I am not sure what to do. I’m mainly having trouble with the pickup tutorial. But for now I think i’ll just continue the tutorial and see if I run into any other errors that’ll lead me back to where the original problem is.
Heres a download link from google drive, let me know if it’s the correct link otherwise ill look further into sending the correct link.Google Drive: Sign-in
I found the problem while doing the next video, and I beheaded it. It was a dang bracket within an if statement. Just a bracket and it caused the game to exit haha