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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Applying Torque in Local Space on a Physics-driven Pawn

I have a physics driven Pawn and I'm currently trying to add turning using 'Add Torque' and 'Set Angular Velocity'. But it seems that these functions are world-space aligned, which is the opposite of what I want: I need this to be aligned to the mesh itself. Right now, Add Torque and any other rotation stuff in physics always works in world space, which is the opposite of what I need.

I asked the same thing here in the forum: https://forums.unrealengine.com/showthread.php?123979-Applying-local-angular-velocity-in-a-Physics-driven-Actor&p=599704#post599704

Product Version: UE 4.13
Tags:
more ▼

asked Sep 25 '16 at 03:05 PM in Blueprint Scripting

avatar image

Xaymar
188 19 28 113

avatar image Podgyhodgy May 03 '17 at 05:18 PM

I have given a blueprint example here that might help you.

blueprint torque in local space

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

2 answers: sort voted first

Hi Xaymar,

Here's the solution that I found for this issue

This will add body-space aligned torque to your object

in cpp (From Actor Component C++ )

 AActor *cubeActor = GetOwner();
 FQuat myActorQuat = cubeActor->GetActorQuat();


 TArray<UStaticMeshComponent*> Components;
 cubeActor->GetComponents<UStaticMeshComponent>(Components);
 
     UStaticMeshComponent* StaticMeshComponent = Components[0];
     UStaticMesh* StaticMesh = StaticMeshComponent->StaticMesh;        
     GEngine->AddOnScreenDebugMessage(-1, 15, FColor::Green, StaticMesh->GetName());

     StaticMeshComponent->AddTorque(myActorQuat.RotateVector(FVector(100.0f, 0.0f, 0.0f)), NAME_None, true);


if you use Blueprints try this out

alt text

solution.png (64.1 kB)
more ▼

answered Oct 05 '16 at 01:52 PM

avatar image

ismail.bulbul
63 1 2 5

avatar image Xaymar Oct 11 '16 at 10:48 AM

Thank you, I went with your approach since it was easier than the blueprint only approach given on reddit. I might stay in C++ for the entire project now, since even simple things are horribly complicated in blueprint :(

avatar image Samuel Brunner May 13 '19 at 01:36 PM

Thx Man your a GOD !

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

Another potential solution:

I realized I had "use controller pitch / yaw / roll" set to "true" in the details section of my physics-driven pawn. Unchecking those options finally let my pawn rotate freely using AddTorque.

(This was after trying converting the coordinate space on my torque vectors between world and local without any luck.)

alt text

more ▼

answered Nov 17 '16 at 05:22 AM

avatar image

monotoan
101 2 5 8

avatar image Podgyhodgy May 03 '17 at 05:20 PM

I have given a blueprint example here that might help you.

blueprint torque in local space

avatar image lucien70 May 18 '17 at 06:22 PM

thank you very much for your help.

(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