Attach a cable from player 1 to player 2

Hi working on a prototype, basically I am just using the third person character BP for this, I added a socket called “headsocket” and i want a cable actor to attach to that socket and have the end attach to player 2. I am doing the blueprinting in the third person character BP right now. How can I access player 2’s socket if it is the same character?

If you spawn it, than you can get the reference for the actor really easily from the spawn node itself. Promote it to a variable. With Player 1 cast to Player 2 and get the actor variable you created on actor 2. For the actor Input on the cast node use a node called: get actor by class. ( or something similar just type in ‘get by class’ ).

If it is in the Level by Default than just make it spawn into the Level. Ist much easier to get a e that way.

So to make sure i get this, you are suggesting I shouldn’t have the cable in the blueprint of the character correct? This should be spawned by the level blueprint?

No. You have 3 actors to work with ye? The 2 Player amd the cable. You want to connect the players head with a cable. For that you need to set the cable start under the socket in the hierarchy and for the end of it you need to get the socket location of player 2. You will spawn Player 2 from Player 1, so you get a reference to it. From that reference you can get the socket component by using a get component node. When you have the reference on the socket you need to get its location. Events should be: Player spawn at start and add an empty looping timeline after the spawn node, and plug it into the event input of the 'set cable end location' node. The location should be the location of Player 2 socket location.

Eyy sorry you only have 2 actors. Player 1 and 2. You habe the cable on Player 1

Can’t you use a “Get Player Character” node with the player index set to 1? Then use it to set the actor in the cable’s Set End Attach To node, setting the component to the player mesh, and the socket to the socket name.

The easiest is to have 2BP for each character, then you can easily cast to.

Why do you need a different blueprint (type) for each character? No casting is needed. All you need is a handle to the object (actor) instance representing player 2.

As of right now I have 2 actors. 2 spawn locations of the same character BP. The issue I was getting before was if i added the cable to the BP then both spawns had cables sticking out of their heads. I will try what you just mentioned. thanks again.

Here is the start of the attachment, this is in the thirdperson character BP

alt text

Semi working, but its not moving with the character, instead spawning off of the old spawn location. Getting there!

I tried your socket idea and its definitely helping, I just cant get the end location to travel with the player.

To do that you need one thing if I am right. Add a timeline. Double click on it. There will be a loop checkbox around the top middle. Enable looping. Exit the timeline. Plug the Attach To Component execution wire into the start on the timeline. Plug the timelines Update output into the Set Attach End To node. This should work. By the way your way of doing it is very unlogical for me. I will do my own setup. I would create different bps for the 2 Players. In your case there are 2 cables in the world when you only need one. This might cause further issues.

All right I just made a working Version. Here are the screenshots from the Setups and a Little Explanational text.

.

alt text

This is what I came up with. It doesn’t need a timeline node to continually update the world position of the cable. Instead, When Player 2 spawns, that blueprint spawns a Cable Actor, attaching the Cable Actor to its own mesh at the headSocket socket, and attaching the end of the cable to Player 1’s mesh at the headSocket socket. I made Player 2 responsible for spawning the cable, because it seemed the easiest way to make sure both players had spawned before creating the cable. To make it a little cleaner, the actual cable setup is in its own function. A Cable Actor is used instead of a Cable Component, just so there wasn’t an unnecessary extra cable component, but Player 2 could just as easily have spawned a Cable Component instead.

Good job, hope you’ll don’t find bug with time. Can I have a look to your BP if you don’t mind, for personal information?
Or just what I want to know is how you tell your P2 to attach it to P1 only, because it’s the same CharBP

Other than adding a variable to hold the references to the other player and the cable, those pictures show all the changes I made. I’m happy to share it, but don’t know how other than by taking pictures. The forum won’t allow me to upload the uasset file Is there a better way?

Basically, it compares a reference to “self” to a reference to the object representing player index 0. If they are identical, then this instance is player 1. If not, then it is player 2. It is the same blueprint, but two different objects instantiating that blueprint.

Thanks, this looks awesome - I will give it a shot and report back. thank you for your time

thanks a lot, I will sift through these options and see what works back. I will let you know if it works!