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"

How can I change the size of an UMeshComponent using C++?

Hey! I was wondering if I can manipulate the Mesh like I can in Blueprint (adjusting its size, position and rotation like I could with a blueprint mesh component). Just asking, because I really prefer using C++ and am not to keen into learning how to use Blueprint only to use it a few times for Mesh components.

Here is my script:

 /** Mesh component in the head script */
     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Mesh)
     TSubobjectPtr < class UStaticMeshComponent> MeshComp;

     // Create the mesh component (in the execution script)
     MeshComp = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Collectable"));
     MeshComp->SetOnlyOwnerSee(false);            // all players will see this meshs
     MeshComp->bCastDynamicShadow = true;
     MeshComp->CastShadow = true;

Thank you in advance!

Product Version: Not Selected
Tags:
more ▼

asked May 05 '14 at 05:35 PM in C++ Programming

avatar image

Borzi
174 43 39 47

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

1 answer: sort voted first

SceneComponent.h

What you want is SceneComponent.h! (A Mesh Component is a Scene Component)

 /** Set the location of this component relative to its parent */
     UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
     void SetRelativeLocation(FVector NewLocation, bool bSweep=false);
 
     /** Set the rotation of this component relative to its parent */
     UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
     void SetRelativeRotation(FRotator NewRotation, bool bSweep=false);
 
     /** Set the transform of this component relative to its parent */
     UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
     void SetRelativeTransform(const FTransform& NewTransform, bool bSweep=false);
 
     /** Returns the transform of this component relative to its parent */
     UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
     FTransform GetRelativeTransform();
 
     /** Set the transform of this component relative to its parent */
     UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
     void ResetRelativeTransform();
 
     /** Set the non-uniform of this component relative to its parent */
     UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
     void SetRelativeScale3D(FVector NewScale3D);
 
     /** Adds a delta to the translation of this component relative to its parent */
     UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
     void AddRelativeLocation(FVector DeltaLocation, bool bSweep=false);
 
     /** Adds a delta the rotation of this component relative to its parent */
     UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
     void AddRelativeRotation(FRotator DeltaRotation, bool bSweep=false);

World Space

The above are in Relative Space relative to Parent

You can also set World Space location and rotation

 /** Set the relative location of this component to put it at the supplied location in world space. */
     UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
     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|Orientation")
     void SetWorldRotation(FRotator NewRotation, bool bSweep=false);
 
     UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
     void SetWorldScale3D(FVector NewScale);
 
     UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
     /** Set the transform of this component in world space. */
     void SetWorldTransform(const FTransform& NewTransform, bool bSweep=false);


Enjoy!

Rama

more ▼

answered May 05 '14 at 07:16 PM

avatar image

Rama
10.6k 446 343 1085

avatar image Borzi May 05 '14 at 07:29 PM

Thanks, looks very detailed! :)

(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