x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

GetWorldRotation of UStaticMeshComponent in C++

Hello, i've spent 3 days to find any way to do this in C++ and stuck on this part. Currently, i lerp whole player, but i need to lerp only PlayerMesh, it wasn't a big deal so i ignored it after few hours of searching. Now i NEED to find PlayerMesh location to spawn projectiles, but currently i stuck at dead end:

 UStaticMeshComponent* pMesh;
 
 pMesh = Cast<UStaticMeshComponent>(GetOwner()->GetComponentByClass(UMeshComponent::StaticClass()));

So, now i think that i'm doing it wrong and more important -> i can't get it Rotation and Location. Thank you! alt text

Product Version: UE 4.21 Preview
Tags:
more ▼

asked Oct 24 '18 at 07:10 PM in C++ Programming

avatar image

Engylizium
8 1 1 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first
  1. To make it work i used UMeshComponent instead of UStaticMeshComponent.

  2. Don't GetOwner() when call GetComponentByClass() or it would crash UE4 It's all working now thanks to that simple things

more ▼

answered Oct 24 '18 at 09:41 PM

avatar image

Engylizium
8 1 1 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

You are looking for GetComponentLocation() and GetComponentRotation().

more ▼

answered Oct 24 '18 at 08:06 PM

avatar image

Steve SybrSyn
1.5k 4 5 10

avatar image Engylizium Oct 24 '18 at 08:12 PM

Yep, it's obvious. I need to know how i can get GetComponent...() for PlayerMesh UStaticMeshComponent and proper way to get this PlayerMesh in C++ if i did it wrong.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question