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"

Set the position of an AActor relative to an other AActor

Hallo Community.

I do want to set the position of an AActor relative to an other AActors position.

  • when the actor A touches the actor B, the physical simulation of B will be deactivated, and B will move relatively to A.

  • Is it possible that actor A’s physics will also considers the mesh and weight of actor B?

  • In my opinion it would be possible to realise this while updating B’s position every tick. But this would be a massive wast of resources.

Is there a better way to realise this problem?

Ps. The overlap event and deactivating the physical simulation is not the problem. It’s all about the updating relative position of B.

Thank you very muche for your help!

Product Version: UE 4.15
Tags:
more ▼

asked Oct 27 '17 at 02:40 PM in C++ Programming

avatar image

ogermann
6 1 2 3

avatar image Flash7 Oct 27 '17 at 02:46 PM

Have you tried "attach to actor"?

avatar image ogermann Oct 31 '17 at 09:15 AM

Thank you very muche for your fast answer. Yes, I tried it. And you are right, this attaches the actor to the other actor. Unfortunately dose this do not have any effect to the mesh. How can I bind the mesh to the actors component?

I use for the “attacher”:

     if(overlappingObjects.Num()>1){
         AActor* BasicObject = overlappingObjects[0];
         for(AActor* A:overlappingObjects){
             if(BasicObject!= A){
                 
                 A->AttachToActor(BasicObject,FAttachmentTransformRules(EAttachmentRule::KeepWorld, true));
                  
             }
         }
     }

And for the other object:

 AStoneBrick::AStoneBrick()
 {
      // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
 
     this->Scene = CreateDefaultSubobject<USceneComponent>(TEXT("Scene"));
     this->RootComponent = Scene;
 
     this->ObjectMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
     this->ObjectMesh->AttachTo(RootComponent);
     this->ObjectMesh->SetSimulatePhysics(true);
     this->ObjectMesh->SetNotifyRigidBodyCollision(true);
 
 }


what am I doing wrong? Thank you very muche!

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
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