Download

How to use/write "GetComponentLocation" in c++

Hello, I’m very new to c++. I’m trying to to get the world location of a Component but i keep getting a pointer error. I don’t understand why i’m getting this error or what to do. I’ve tried multiple ways of writing it out but nothing works. I also went searching online for how to use “GetComponentLocation” but there is little to no help with any c++ code and the UE4 API doesn’t help someone new like me at all. Its probably very simple fix. If someone out there could tell me what to do or write an example of using this function as it would only take a few minutes , Thanks!

btw i was using: USceneComponent::GetComponentLocation

Please refer to the image i’ve included

Hi! I’m very new to c++
UPrimitiveComponent
For this particular IntelliSense error, the fix is to add the header: #include “Components/PrimitiveComponent.h”

Use Startcomp->GetComponentLocation()

Edit: removed the lies ><

Side note: the first if condition is also bugged, it should read
​​​​​​
if(!CompStart || !CompEnd)

This is how you do it:



FVector Location = CompStart->GetComponentLocation();



Primitive Component does have a location, it inherits from Scene Component.

Thanks! that did the trick

And thanks to everyone else for the help!

Thanks Jamsh, I read the documentation poorly. ><