(Animation) how to make an hostage situation

hi, how can i make an hostage situation? i have found the animations on mixamo website

221586-hostage.png

221587-villain.png

Attach skeletal mesh of hostage to this character or as child blueprint maybe. For sure you have to disable/change a lot of attached character behaviors, collision, movement etc.This is start, but it need some nice code.

I created a new socket (hostage_attach). how can I attach the victim to this socket when I press a specific key?

You should check distance first - if is in range, it can be attached.

My solution is fast for some directions only, but whole system need much more work and your decision how it should work and I’m sure here more different solutions.

Generally you should look for basic documents from Epic how to attach components or actor to actor.

Here very dirty sample, how to attach to actor or component:

https://i.imgur.com/Yg6rRfP.png

On Key H press - attach (different way).

This need much more code like a this distance check, or better collision and do a lot of other changes in hostage actor or mesh, and this all would be good for not short tutorial. Here I can give you directions only and this from answer is again - one of many solutions, maybe even not best.

You can use child actor node. I can’t check it now, but for sure you can attach child blueprint actor this way. try first with attached on spawn.

Does this only work with the right actors?
because I would like to make it work with a blueprint character

You can have bad Cast to or you (always preferable) should add IsValid to HostageBP. Sometimes one of blueprint can’t see yet cast to blueprint and IsValid is for avoid this error message, however if it not working at all, problem is elsewhere. But IsValid anyway is good to use here.

PIE: Error: Blueprint Runtime Error: Accessed None trying to read property HostageBP from function: ‘ExecuteUbergraph_robotBP’ from node: AttachToComponent in graph: EventGraph in object: robotBP with description: Accessed None trying to read property HostageBP

Nothing, if I try to attach an actor to the socket, all works. but if I try to attach hostage character (present in the level) to the socket, it does not work

I have it worked. Simple attach. In my case I use fps template, but with third person this is same.

here is before:

https://i.imgur.com/9ZqGP8S.png

here is result:

https://i.imgur.com/EbqIX7a.png

I can walk with this character attached where I want. It need more code, but attaching work as expected.

Here is attached to component weapon on muzzle:

https://i.imgur.com/TVpXPEc.png

Here code:

https://i.imgur.com/F1okBuE.png

Code is in Player blueprint. On screen when player is overlap by this character UE4ASP…, character is attached to weapon in socked muzzle.

This works also with attach to actor, but I think to component is better. Anyway, it need still a lot of code, but this character is attached and player can walk everywhere.

You can add code to start it with button or whatever you want.

You have to change character collision on hostage - it should overlap not block to check player is overlap.

ok actually works this way, but I did not quite understand how to activate it with a key

forgive me for my ignorance and for my bad English

This is how it works with button (I have on Enter, other I have in use already, you can use any other button - E for example):

https://i.imgur.com/You3WuG.png

This is no production solution, just fast and easy example. It will work when hostage overlaps player only and with hostage only, not other characters. You have to change UE4…character with your hostage blueprint.

Here other solutions with binding events, but this is simpler and easy to understand.

I think it works, but the hostage falls into the void, there must be a problem with the collisions. would I be wrong to set them up?

If falls, it must be wrong socket or something. I have on rifle this socket, try instead of rifle Mesh and socket on this Mesh you created.

It working in my project, I test it and ‘hostage’ is correctly attached.

Post your hostage view and it collision settings and this Key action I post above how you did it. Maybe I can check this tomorrow, today I’m out.

ok, it fell because I had set the capsulecomponent collision on “overlap all dynamic”
Now I’ve reset the collisions to the initial state, maybe we can easily fix it by setting the collisions well.
do I have to modify the mesh collisions or collisions of the component capsule?

how can I release the hostage after I have attached him?

Do you have correct collision now? I can’t check project where I created this test now. And to be honest, it need whole tutorial not simple answer to question, that I think is answered already and you should select it as answered. You can post additional question when other problems in this hostage thing.
This hostage release I can post later, it need detach from actor (or component) not sure from memory, back movement on and change collision maybe. Also it need to restart Behavior Tree if hostage is AI and a lot of other work, so this is really no place for that detailed and extensive solution :slight_smile:
But I like this idea (hostage) and I will add it to my game I think, maybe just as some kind of incapacitation, but it need some time to make production bp and after that I can tell you more.