Why is there no SetComponentRotation() for USceneComponent?

I can call on GetComponentRotation(), but I wanted to set the component’s rotation. In a no-gravity scenario, since a UStaticMeshComponent has no physics body, I cannot call on AddForce() in the UStaticMeshComponent.BodyInstance to keep it upright. It’s just not possible to keep the mesh upright even after bumping into objects in a weightless scenario.

I wondered why?

Solutions For You!

  1. Static Mesh components surely can have physics bodies, just make sure to set the static mesh to Mobility Movable

  2. Actually you absolutely can set the world rotation of a scene component, you can even add to Rotation/Location/Transform!

So in case it is not clear, SetComponentLocation == SetWorldLocation and the one you want, SetComponentRotation == SetWorldRotation

Because the ComponentToWorld Transform is what you are working with in the case of SetComponentLocation.

For the getters it is generally GetComponent… but for the setters it is SetWorld

I do agree this naming scheme could be unified at some point.


**From SceneComponent.h**

You've got many options!



```


/** Set the relative location of this component to put it at the supplied location in world space. */
UFUNCTION(BlueprintCallable, Category="Utilities|Transformation")
void SetWorldLocation(FVector NewLocation, bool bSweep=false);

/** Set the relative rotation of this component to put it at the supplied orientation in world space. */
UFUNCTION(BlueprintCallable, Category="Utilities|Transformation")
void SetWorldRotation(FRotator NewRotation, bool bSweep=false);

/** Set the relative scale of this component to put it at the supplied scale in world space. */
UFUNCTION(BlueprintCallable, Category="Utilities|Transformation")
void SetWorldScale3D(FVector NewScale);

/** Set the transform of this component in world space. */
UFUNCTION(BlueprintCallable, Category="Utilities|Transformation")
void SetWorldTransform(const FTransform& NewTransform, bool bSweep=false);

/** Adds a delta to the location of this component in world space. */
UFUNCTION(BlueprintCallable, Category="Utilities|Transformation")
void AddWorldOffset(FVector DeltaLocation, bool bSweep=false);

/** Adds a delta to the rotation of this component in world space. */
UFUNCTION(BlueprintCallable, Category="Utilities|Transformation")
void AddWorldRotation(FRotator DeltaRotation, bool bSweep=false);

/** Adds a delta to the transform of this component in world space. Scale is unchanged. */
UFUNCTION(BlueprintCallable, Category="Utilities|Transformation")
void AddWorldTransform(const FTransform& DeltaTransform, bool bSweep=false);


```



Enjoy!

Rama

It worked! Thank you!

Turns out that the naming scheme for setting a component’s rotation is confusing for me, so I have submitted a feedback to Epic requesting that the naming scheme be unified nicely.