Download

Teleporting with hand controllers Crash! Why!?

When I change from camera to Right or LeftController I get this. The compilation in VS and Unreal is fine but after, when I press start unreal is crash.

FVector Start = LeftController->GetComponentLocation();

FVector End = Start + LeftController->GetForwardVector() * MaxTeleportDistance;

//FVector Start = Camera->GetComponentLocation();

//FVector End = Start + Camera->GetForwardVector() * MaxTeleportDistance;

I Think the problem is here, in the inicialitation but I don’t know why. Pointers are initialized in the class constructor but It tell me that they aren’t inicialitation when I’m checking with a if. I’ve trying several things but it not work. I need some help.
The controllers are visible and its inputs are working well if I don’t use its code, right.

You could try setting a data breakpoint in VS to see when & why the pointers to your controllers are invalidated. https://devblogs.microsoft.com/cppblog/data-breakpoints-15-8-update/

Hello MPalacios. Thank you for your answer. I did a breakpoint and this is the result. UPrimitiveComponent is null. What can I do? Sorry but I’m a beginner in the programing.

Yeah it’s saying the LeftController is null. The reason I recommend a data breakpoint specifically is that you can specify it to trigger a breakpoint when a certain condition is met. I.e when the object becomes null. Then you’ll see the stack trace for where and why it was deleted.
But if I’d have to guess it could be that LeftController and RightController aren’t tagged as UPROPERTY() in your .h file?

Yeah, they are tagged as UPROPERTY().