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"

Attach/Detach static mesh component to/from socket

I'm trying to attach a static mesh component (weapon) to my character's skeletal mesh component's socket and then allow it to be detached, re-attached, re-detached, etc....

The problem is I can'r re-attach it a second time. Here's how it goes right now: - Attach weapon for first time, it attaches to socket. Perfect. - Detach weapon, it drops to the floor. Perfect. - Try to attach it again. It stays on floor. Not perfect.

It works ok if I don't set the Set Simulate Physics to TRUE when detaching the weapon. But, I don't want the weapon to be floating in mid-air, I want it to drop to the floor.

Here's the attach blueprint: alt text

And, here's the Detach blueprint script: alt text

Product Version: UE 4.10
Tags:
attach.jpg (178.0 kB)
detach.jpg (70.1 kB)
more ▼

asked Mar 21 '16 at 05:40 PM in Blueprint Scripting

avatar image

sylercider
23 1 2 6

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

1 answer: sort voted first

You need to setup a way to turn simulate physics off once you have completed the detach otherwise after the detach happens it will remain as simulating physics and won't attach back to the socket normally. You may need to set it up as a BP so you can call a function on it to turn off simulate physics when you go to pick it up again.

more ▼

answered Mar 21 '16 at 10:24 PM

avatar image

Black Phoenyx
4.1k 165 9 169

avatar image sylercider Mar 21 '16 at 11:33 PM

The weapon is a BP. The attach/detach images above are from the weapon's BP.

I set the simulate physics off right before I attach the weapon to my character. And I set it on right before I detach it from my character.

avatar image Black Phoenyx Mar 21 '16 at 11:57 PM

Is the mesh the root component in the weapon BP?

avatar image sylercider Mar 28 '16 at 11:54 PM

The Static Mesh comes after the DefaultSceneRoot:

alt text

mesh.jpg (17.7 kB)
avatar image Black Phoenyx Mar 29 '16 at 12:06 AM

Oh ok, I think maybe it is dropping away from the root when you simulate physics on the mesh and the root is staying where it was....I think the mesh is moving away from the SceneRoot basically... try testing it with the mesh as the root component.

avatar image sylercider Mar 29 '16 at 01:35 AM

The problem I'm having now is that each weapon I have is a child class of the main weapon BP, just with different meshes. If I position one of the weapons correctly in the skeleton, it affects how ALL of the weapons are positioned. How do I set the position of each weapon correctly? I can't adjust each weapon's mesh in the blueprint because they're now the root.

avatar image Black Phoenyx Mar 29 '16 at 01:42 AM

At what point are you turning simulate physics off?

avatar image sylercider Mar 29 '16 at 01:45 AM

Right before I call AttachActorToComponent

avatar image Black Phoenyx Mar 29 '16 at 01:55 AM

Ok you need to move the root when you do that so try something like this with the weapon setup as it was originally so you don't have to do a bunch of extra work with sockets/locations:

alt text

This should be inline with setting simulate physics to false....so what should happen is just as you turn off simulate physics the root should move to match the weapon mesh location and then it should snap back to the socket normally.

avatar image sylercider Mar 29 '16 at 02:54 AM

OK, I get it, thanks.

I could also set the Pitch/Yaw/Roll of the mesh. That would set it permanently, right?

avatar image Black Phoenyx Mar 29 '16 at 03:02 AM

Yeah until you set it again...something you could setup on begin play is the mesh transform and then when you move the root you could reset the mesh to its begin play transform.

avatar image sylercider Mar 29 '16 at 03:15 AM

OK, so to recap for anyone with this same problem...

  • Make the Static Mesh the DefaultSceneRoot

I'll play around with the different options for getting the mesh to fit correctly in the socket.

Thanks so much for your help, Black Phoenyx!

(comments are locked)
10|2000 characters needed characters left
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