I’ve started from the Unreal example of flying in c++. I’ve added some classes to the project, but when I press play the UE Editor crashes even if I remove the newly added classes. I attach the log
I don’t see any crash from the log file. Are you sure this is the right one?
I confused log files, here is the right one: link text
Looks like a null pointer exception. Double check/debug these two functions:
[Callstack] 0x00000000C6941FB0 UE4Editor-Drone_follower.dll!AActorsController::ReturnNewData() [c:\users\4r35\documents\unreal projects\drone_follower\source\drone_follower\actorscontroller.cpp:42]
[2018.02.09-17.32.43:147][383]LogWindows: Error: [Callstack] 0x00000000C69428D6 UE4Editor-Drone_follower.dll!ABall::Tick() [c:\users\4r35\documents\unreal projects\drone_follower\source\drone_follower\ball.cpp:44]
Yes, but I does not found any error in these functions…
actorscontroller.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "ActorsController.h"
#include "Drone_follower.h"
#include "Messages.h"
#include "CustomData.h"
#include "EngineUtils.h"
// Sets default values
AActorsController::AActorsController()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
//Istantiate Communication Component
OurCommunicationComponent = CreateDefaultSubobject<UUDP_Component>(TEXT("Communication Component"));
}
// Called when the game starts or when spawned
void AActorsController::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AActorsController::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// Get Data
OurCommunicationComponent->GetData(&ReceivedData); //Store in a local variable the received data
//Serialize received data
/*for (i = 0; i < sizeof(struct FCustomPoseData); i++){
*((uint8*)(&VehiclePose) + i) = ReceivedData[i];
}*/
}
void AActorsController::ReturnNewData(FCustomPoseData *NewData) {
*NewData = ReceivedData;
}
void AActorsController::PreInitializeComponents() {
Super::PreInitializeComponents();
OurCommunicationComponent->StartUDPComm("PawnCommunicationComponent");
}
Ball.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "Ball.h"
#include "Messages.h"
#include "CustomData.h"
#include "ActorsController.h"
#include "Drone_follower.h"
// Sets default values
ABall::ABall()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
SetActorLocation(FVector(0.0f, 0.0f, 29.0f));
//Instantiate static mesh component
BallVisibleComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BallVisibleComponent"));
//Get actor controller pointer
//Get ActorsController pointer for receiving position
for (TObjectIterator<AActorsController> Itr; Itr; ++Itr) {
if (Itr->IsA(AActorsController::StaticClass())) {
ActorController = *Itr;
}
}
}
// Called when the game starts or when spawned
void ABall::BeginPlay()
{
Super::BeginPlay();
SetActorLocation(FVector(0.0f, 0.0f, 0.0f));
}
// Called every frame
void ABall::Tick(float DeltaTime)
{
FCustomPoseData NewData;
Super::Tick(DeltaTime);
ActorController->ReturnNewData(&NewData);
SetPose(&NewData);
}
void ABall::SetPose(FCustomPoseData* ReceivedData) {
FVector Position;
//Received measures are in cm --> convert into m
Position.X = 100 * ReceivedData->ball_X;
Position.Y = 100 * ReceivedData->ball_Y;
Position.Z = 100 * ReceivedData->ball_Z;
SetActorLocation(Position);
}
Are you sure this is right?
void AActorsController::ReturnNewData(FCustomPoseData *NewData) {
*NewData = ReceivedData;
}
Yes, I do not see any error, is declared here in the ActorsController.h file:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "UDP_Component.h"
#include "CustomData.h"
#include "ActorsController.generated.h"
UCLASS()
class DRONE_FOLLOWER_API AActorsController : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AActorsController();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
virtual void Tick(float DeltaTime) override;
virtual void PreInitializeComponents() override;
void ReturnNewData(FCustomPoseData* NewData);
private:
UPROPERTY(EditAnywhere, Category = "Remote Address")
class UUDP_Component* OurCommunicationComponent;
FCustomPoseData ReceivedData;
};
I believe the problem is in this assignment:
*NewData = ReceivedData;
How are you allocating memory to the pointer before the assignment?
The Ball class creates a local variable and then calls that method:
FCustomPoseData NewData;
Super::Tick(DeltaTime);
ActorController->ReturnNewData(&NewData);
Hello,
We’ve recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.
Thanks