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. 

MakeRotationFromAxes gives me wrong results

Hello everyone, I'm trying to calculate a new reference system based on a normal vector. This appears to be more complicated than I thought and I think I am stuck because of a potential bug with MakeRotationFromAxes or FMatrix (but I could be using it wrong).

In short if I try to get this rotator:

         rotation = UKismetMathLibrary::MakeRotationFromAxes(-FVector::ForwardVector, -FVector::RightVector, -FVector::UpVector);

I expect it to be upside down, something like this:

  {Pitch=0.000000000 Yaw=180.000000 Roll=180.000000000 }

alt text

but I get this:

 {Pitch=0.000000000 Yaw=180.000000 Roll=0.000000000 }

alt text

that is simply facing back but not upside down. Am I missing something basic? The problem is easily reproduceable (in the pictures I am using the base cone in unreal).

Thank you in advance for your help,


Product Version: UE 4.20
capture.png (67.0 kB)
capture2.png (45.6 kB)
more ▼

asked Sep 23 '18 at 03:37 PM in C++ Programming

avatar image

3 1 2

avatar image NicholasMont ♦♦ STAFF Sep 24 '18 at 05:11 PM

Hello Eibis,

Can you please provide your full class(.cpp) and header file (.h) for this particular class?

avatar image Eibis Sep 24 '18 at 05:56 PM

Hello Nicholas, thank you very much for your answer!

Sure, here is my test: MyStaticMeshActor.h

 // Fill out your copyright notice in the Description page of Project Settings.
 #pragma once
 #include "CoreMinimal.h"
 #include "Engine/StaticMeshActor.h"
 #include "MyStaticMeshActor.generated.h"
 class GEOMETRYRUN_API AMyStaticMeshActor : public AStaticMeshActor
     virtual void BeginPlay() override;

MyStaticMeshActor.cpp // Fill out your copyright notice in the Description page of Project Settings.

 #include "MyStaticMeshActor.h"
 #include "Runtime/Engine/Classes/Components/StaticMeshComponent.h"
 #include "Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h"
 #include "Runtime/Engine/Classes/Kismet/KismetMathLibrary.h"
 AMyStaticMeshActor::AMyStaticMeshActor() : AStaticMeshActor()
     static ConstructorHelpers::FObjectFinder<UStaticMesh> Mesh(TEXT("StaticMesh'/Game/StarterContent/Shapes/Shape_Cone.Shape_Cone'"));
 void AMyStaticMeshActor::BeginPlay()
     FRotator rotation = UKismetMathLibrary::MakeRotationFromAxes(-FVector::ForwardVector, -FVector::RightVector, -FVector::UpVector);

I get the same result of my second screenshot, with these values as rotation: {Pitch=0.000000000 Yaw=180.000000 Roll=0.000000000 }


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

1 answer: sort voted first

Hey Eibis,

The issue you're experiencing may be a physics error. when you call MakeRotationFromAxes the negative operand values you are providing are "cancelling each other out".

Instead, you only need to negate the x or y value to get your desired rotation.

For Example:

Here we will make the ForwardVector(X) negative.

 FRotator rotation = UKismetMathLibrary::MakeRotationFromAxes(-FVector::ForwardVector, FVector::RightVector, FVector::UpVector);

This will yield the following:

alt text

Here we make the Right Vector(Y) negative

 FRotator rotation = UKismetMathLibrary::MakeRotationFromAxes(FVector::ForwardVector, -FVector::RightVector, FVector::UpVector);

This will yield the following: alt text

more ▼

answered Sep 24 '18 at 08:08 PM

avatar image

NicholasMont ♦♦ STAFF
592 3 4 6

avatar image Eibis Sep 25 '18 at 08:35 AM

Thank you for your answer, I understand the problem now ^^


(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