Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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
    Click image for larger version

Name:	Pointer..PNG
Views:	14
Size:	54.6 KB
ID:	1669984

    #2
    Hi! I'm very new to c++
    UPrimitiveComponent
    For this particular IntelliSense error, the fix is to add the header: #include "Components/PrimitiveComponent.h"
    GitHub Repo - WIP RPG

    Comment


      #3
      Use Startcomp->GetComponentLocation()


      Edit: removed the lies ><
      Last edited by Telimaktar; 10-08-2019, 01:53 AM.
      SolidGasGames

      Comment


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

        Comment


          #5
          This is how you do it:
          Code:
          FVector Location = CompStart->GetComponentLocation();
          ---

          Originally posted by Telimaktar View Post
          PrimitiveComponent doesn't have location, SceneComponent does however, once you update your method signatures to SceneComponent you will have access to Startcomp->GetcomponentLocation()
          Primitive Component *does* have a location, it inherits from Scene Component.

          Comment


            #6
            Originally posted by TheJamsh View Post
            This is how you do it:
            Code:
            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!

            Comment


              #7
              Originally posted by TheJamsh View Post
              This is how you do it:
              Code:
              FVector Location = CompStart->GetComponentLocation();
              ---


              Primitive Component *does* have a location, it inherits from Scene Component.
              Thanks Jamsh, I read the documentation poorly. ><
              SolidGasGames

              Comment

              Working...
              X