Trying to make a blueprint callable function that takes lat,lon,altitude as floats and converts them to a UE vector so I can move actors around. When I call the function UE crashes with an exception error.
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000388
UE4Editor_CesiumRuntime!CesiumGeospatial::Ellipsoid::cartographicToCartesian()
UE4Editor_CesiumRuntime!GeoTransforms::TransformLongitudeLatitudeHeightToUnreal() [D:\build\++Portal\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\CesiumForUnreal\Source\CesiumRuntime\Private\GeoTransforms.cpp:109]
UE4Editor_CesiumRuntime!ACesiumGeoreference::TransformLongitudeLatitudeHeightToUnreal() [D:\build\++Portal\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\CesiumForUnreal\Source\CesiumRuntime\Private\CesiumGeoreference.cpp:833]
I have a feeling it has to do with the GeoReference variable in my actor instance, I see the georeference in the list but when I click it, nothing happens. I also added a CesiumGlobeAnchor component to the actor but it still crashes. Any ideas?
Here’s my header…
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "CesiumGeoreference.h"
#include "Math/Vector.h"
#include "CesiumGeospatial/Ellipsoid.h"
#include "CesiumGeospatial/Cartographic.h"
#include "aircraft_4.generated.h"
UCLASS()
class ADSB_API Aaircraft_4 : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
Aaircraft_4();
// A pawn from the Cesium for Unreal API that can convert between different coordinates
UPROPERTY(EditAnywhere, Category = "FlightTracker")
ACesiumGeoreference* CesiumGeoreference;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
UFUNCTION(BlueprintCallable, Category = "calc")
void getUePos(const float lat, const float lon, const float altitude, FVector& out);
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
and my code
// Fill out your copyright notice in the Description page of Project Settings.
#include "aircraft_4.h"
#include "Runtime/Engine/Public/EngineGlobals.h"
// Sets default values
Aaircraft_4::Aaircraft_4()
{
// 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;
}
// Called when the game starts or when spawned
void Aaircraft_4::BeginPlay()
{
Super::BeginPlay();
}
void Aaircraft_4::getUePos(const float lat, const float lon, const float altitude, FVector& out)
{
float altitude_m = altitude * 0.3048;
glm::dvec3 UECoords = this->CesiumGeoreference->TransformLongitudeLatitudeHeightToUnreal(glm::dvec3(lat, lon, altitude_m));
out = FVector(UECoords.x, UECoords.y, UECoords.z);
}
// Called every frame
void Aaircraft_4::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
The blueprint currently doesn’t do anything with the output vector. I even changed the function to not have a return or do anything else but do the transform and it still crashes so it must be that line. Not really experienced with unreal or c++ so I’d appreciate any help you can give. Thanks