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 detach an Actor's RootComponent from another Socket?

I've attached one of my Blueprints programmatically to my Character's RightHandSocket using the following:

 //TestCharacter.cpp
 
 MyItem = GetCurrentlyEquippedItem(); //Gets the thing to attach
 MyItem->AttachRootComponentTo(this->Mesh, "RightHandSocket", EAttachLocation::Type::SnapToTarget); // Attaches the item to my character's right hand.
 
 

However, I'd like to detach it from that socket later on, in the case of the player dropping the item. I haven't been able to find anything in the AActor page that resembles "detaching", so I wonder if I'm looking in the wrong spot?

Product Version: Not Selected
Tags:
more ▼

asked May 18 '14 at 12:36 AM in C++ Programming

avatar image

Acidictadpole
47 6 9 14

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

3 answers: sort voted first

I think what you can do is get your root component and call

DetachFromParent()

This is called from the component itself... not the Actor.

more ▼

answered May 18 '14 at 12:47 AM

avatar image

AnxGotta
1.6k 61 45 237

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

The Solution

 MyItem->DetachRootComponentFromParent();

Doesn't matter what/who the parent is :)

Actor.h

 /** 
  *  Detaches the RootComponent of this Actor from any SceneComponent it is currently attached to. 
  *   @param bMaintainWorldTransform    If true, update the relative location/rotation of this component to keep its world position the same
  */
 UFUNCTION(BlueprintCallable, meta=(FriendlyName = "DetachActorFromActor"), Category="Utilities|Orientation")
 void DetachRootComponentFromParent(bool bMaintainWorldPosition = true);


Rama

more ▼

answered May 18 '14 at 12:44 AM

avatar image

Rama
10.6k 446 346 1088

avatar image Acidictadpole May 18 '14 at 01:02 AM

Okay thanks. I'll try it. I thought the parent would be something other than what I attached it to.

avatar image AnxGotta May 18 '14 at 01:14 AM

The AttachTo or AttachRootComponentTo method sets the object as the parent of the object you are attaching.

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

I´m facing a similar problem

attaching like this MyItem->AttachRootComponentTo(this->Mesh, "RightHandSocket", EAttachLocation::Type::SnapToTarget);

works properly

but MyItem->DetachRootComponentFromParent();

seems not being working. I would expect MyItem to get freed in the scene, but keeps moving attached to my character

any thoughts? Thanks in advance

more ▼

answered May 13 '15 at 03:44 PM

avatar image

Hernán
1

(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