Prevent Actors rotation

Hi all! Is there any other way to prevent Actor’s component from rotation except of overriding Actor’s Tick() function and explicitly calling SetAllPhysicsRotation(FRotator(0, 0, 0)) on a component? Engine 4.6.1. Thanks!

Hello ArtysS,

There are two ways:

You can create constraint and restrict actor rotation. See post below How do I make a pushing box - Blueprint - Epic Developer Community Forums

You can setup inertia to zero vector. I think this way is more correctly, because it has no additional restriction, but unfortunately, you should do that through physx interface

// Add ‘physx’ module dependency
#include "PxVec3.h"
#include "PxRigidBody.h"

void ANonRotatableStaticMeshActor::BeginPlay()
{
	auto pComponent = Cast<UStaticMeshComponent>(RootComponent);
	if (pComponent && pComponent->GetBodyInstance() && pComponent->GetBodyInstance()->GetPxRigidBody())
		pComponent->GetBodyInstance()->GetPxRigidBody()->setMassSpaceInertiaTensor(physx::PxVec3(0, 0, 0));
}

Hope it helps!

I know this is an old question, but I’m going to add some updated info for those who need it, since the physx header files above are no longer correct (at least they didn’t work for me). The header files you actually need now are:

#include “PhysXIncludes.h”
#include “PhysicsPublic.h”
#include “PhysXPublic.h”

You also need to edit your Build.cs file to include Physx and APEX, as in:

PublicDependencyModuleNames.AddRange(new string[] { “Core”, “CoreUObject”, “Engine”, “InputCore”, “PhysX”, “APEX” });

Further information on getting physx code to work can be found at these links:

It took me several days to figure this out, so hopefully I can save someone the future trouble. Setting the inertia to zero works great, by the way.