Parenting entity to players

Macanick

L1: Registered
Dec 12, 2016
45
8
I think i ask the question wrong last time so i just make another thread...

I found you can parenting entities to player but i can't found detailed information about player parent.
i don't have much information about them like player bone or somthing so i'm glad if you teach me how to do this step by step, just change targetname of activator is not working for me(using button, on pressed - activator - addoutput - targetname [name] and setparent wont work :( ).
sorry but i'm not that good at English so i want you to explain in detail, thanks for reading
 

lunarpumpkin

L2: Junior Member
Aug 31, 2016
72
15
the only thing i ever made was a laser that shoot people when they shoot a button , but they need to be the activator of the button for it to register , you change the activator tag to "tag you want to be" then you teleport the entity to that tag, add me on steam ill prepare a vmf for you to use as exemple

http://steamcommunity.com/id/QUAKEMAN00/
 

Diva Dan

hello!
aa
Mar 20, 2016
1,024
1,951
Like I said in the other thread, I'm pretty sure the only way you can parent something to a player is if you use an intelligence flag or PASS time jack. you can parent entities and brush entities to flags and jacks, and since the flag is patented to the player, you basically have the entities patented to your body. You can teleport the flag to the player whenever they drop it (there is an output OnDropped) so they can't just remove the flag


I might be wrong though- this page is old but has useful info http://gamebanana.com/threads/171680
 

lunarpumpkin

L2: Junior Member
Aug 31, 2016
72
15
no , ive got a laser to folow someone and get people teleported by changing thier "player" flag this come with alot of issue like "if the player die during the teleprot flag before being reassined the player flag , theyll be stuck being teleported for ever to the teleport spot" but there is defenetly a way to get stuff to folow a player or force a player to go somewehre
 

14bit

L14: Bit Member
aa
Oct 5, 2014
642
2,066
You can parent any parentable objects directly to players if you mange to give each player a unique targetname and target the correct bone when parenting. ctf_eggwar has a mechanism that names every player to make the shrinking work, but you could use the same mechanism for your own use.

Here's a write-up that ABS made about the entity systems in that map: https://tf2maps.net/threads/egg-war-mechanical-logic-and-other-complexities.22398/

It's quite complicated and it'll probably be difficult to reproduce right now because the images in this are broken (probably due to Dropbox's recent changes), but it's doable. Just keep in mind that not all entities will function properly when parented, if I recall trigger_multiples don't seem to work when parented to players.

You'll have to fight a bunch of issues with players dying and keeping everything parented properly when players join and leave the match. I have done it on a small scale before, but I do not believe I still have the map file. It's a quite an undertaking to try and get it working, I wish you the best of luck.
 

Macanick

L1: Registered
Dec 12, 2016
45
8
i
You can parent any parentable objects directly to players if you mange to give each player a unique targetname and target the correct bone when parenting. ctf_eggwar has a mechanism that names every player to make the shrinking work, but you could use the same mechanism for your own use.

Here's a write-up that ABS made about the entity systems in that map: https://tf2maps.net/threads/egg-war-mechanical-logic-and-other-complexities.22398/

It's quite complicated and it'll probably be difficult to reproduce right now because the images in this are broken (probably due to Dropbox's recent changes), but it's doable. Just keep in mind that not all entities will function properly when parented, if I recall trigger_multiples don't seem to work when parented to players.

You'll have to fight a bunch of issues with players dying and keeping everything parented properly when players join and leave the match. I have done it on a small scale before, but I do not believe I still have the map file. It's a quite an undertaking to try and get it working, I wish you the best of luck.
i already read that and i can't find anything about parenting... there's only tutorial for shrinking and targetname.
of course that's important and need to know for what i do but i don't know how to parenting entity to players i should know them before making targeting system. sorry but can i borrow your vmf files? that'll be helpful
 

Tumby

aa
May 12, 2013
1,084
1,192
Alrighty then. What you don't seem to understand is that a player is treated like any other entity. It's an entity that only exists ingame, and so we have to set our logic up accordingly. Parenting, naming and anything else is done the same way as with any other entity. Anyways...
You will need:
1. A trigger_multiple brush entity.
2. The entity you want to be parented to the player. Here: A prop_dynamic.

Step 1:
Give the prop_dynamic a 'targetname'. (Often simply called 'name') I will call it Henry.
Step2:
Give the trigger_multiple a new output. This output will be:
OnStartTouch - Henry - SetParent - !activator - (no delay)

If this does not work, you will need to give the player a targetname first.
Alternative Step 2:
The output of the trigger will be:
OnStartTouch - !activator - AddOutput - targetname Bob - (no delay)
AddOutput can be a little hard to get right, but I think it should work like this.
Alternative Step 3:
Take the output from the original Step 2 and replace !activator with Bob: (Quick note: Can be done with any other entity. Replace the first part of the output accordingly.)
OnStartTouch - Henry - SetParent - Bob - (no delay)
This will appear red because hammer can't find any entities called 'Bob'. Ignore that.

If you now want Henry to be placed at a specific bone, you will need the name of that bone first. I can't give you all the bone names right now, so I will use the only one I can remember: bip_head
The output for the trigger will be: (Quick note: Can be done with any other entity. Replace the first part of the output accordingly.)
OnStartTouch - Henry - SetParentAttachment - bip_head - (no delay)
It is very import to note that SetParentAttachment only works after Henry has already been parented.
 
Last edited:

Macanick

L1: Registered
Dec 12, 2016
45
8
Alrighty then. What you don't seem to understand is that a player is treated like any other entity. It's an entity that only exists ingame, and so we have to set our logic up accordingly. Parenting, naming and anything else is done the same was as with any other entity. Anyways...
You will need:
1. A trigger_multiple brush entity.
2. The entity you want to be parented to the player. Here: A prop_dynamic.

Step 1:
Give the prop_dynamic a 'targetname'. (Often simply called 'name') I will call it Henry.
Step2:
Give the trigger_multiple a new output. This output will be:
OnStartTouch - Henry - SetParent - !activator - (no delay)

If this does not work, you will need to give the player a targetname first.
Alternative Step 2:
The output of the trigger will be:
OnStartTouch - !activator - AddOutput - targetname Bob - (no delay)
AddOutput can be a little hard to get right, but I think it should work like this.
Alternative Step 3:
Take the output from the original Step 2 and replace !activator with Bob: (Quick note: Can be done with any other entity. Replace the first part of the output accordingly.)
OnStartTouch - Henry - SetParent - Bob - (no delay)
This will appear red because hammer can't find any entities called 'Bob'. Ignore that.

If you now want Henry to ne placed at a specific bone, you will need the name of that bone first. I can't give you all the bone names right now, so I will use the only one I can remember: bip_head
The output for the trigger will be: (Quick note: Can be done with any other entity. Replace the first part of the output accordingly.)
OnStartTouch - Henry - SetParentAttachment - bip_head - (no delay)
It is very import to note that SetParentAttachment only works after Henry has already been parented.
I LOVE YOUUUUUUUU ★
so it's bone name is same as appearing in sfm?
 

Macanick

L1: Registered
Dec 12, 2016
45
8
As long as you are looking at the ingame player models, of course. The HWM models might be a little bit different, I'm not sure.
ERROR: Tried to SetParentAttachment for entity info_target (head_targ), but it has no attachment named bip_head.
ERROR: Tried to SetParentAttachment for entity info_target (body_targ), but it has no attachment named bip_pelvis.
ERROR: Tried to SetParentAttachment for entity info_target (foot2_targ), but it has no attachment named bip_foot_L.
ERROR: Tried to SetParentAttachment for entity info_target (foot1_targ), but it has no attachment named bip_foot_R.
ERROR: Tried to SetParentAttachment for entity info_target (leg1_targ), but it has no attachment named bip_hip_R.
ERROR: Tried to SetParentAttachment for entity info_target (leg2_targ), but it has no attachment named bip_hip_L.
it seems not working...
 

Tumby

aa
May 12, 2013
1,084
1,192
I don't know about SFM, but a little program called HLMV (Half Life Model Viewer) found in the same directory as hammer (Team Fortress 2/bin) can show you them.
Example:
e9c5965672.png

Click "File">"(Steam) Load Model" and then type "player/(classname).mdl" in the field. Navigating the folders doesn't work for me, so I have to type in the path. You can still get the filepath from hammer's model viewer though.
Anyways, in the "Attachments" tab you can see two lists. The left one are the attachments and the right one automatically shows you the bone that this attachment is, well, attached to. The model viewer will also show you where that attachment is placed.
 

Macanick

L1: Registered
Dec 12, 2016
45
8
I don't know about SFM, but a little program called HLMV (Half Life Model Viewer) found in the same directory as hammer (Team Fortress 2/bin) can show you them.
Example:
e9c5965672.png

Click "File">"(Steam) Load Model" and then type "player/(classname).mdl" in the field. Navigating the folders doesn't work for me, so I have to type in the path. You can still get the filepath from hammer's model viewer though.
Anyways, in the "Attachments" tab you can see two lists. The left one are the attachments and the right one automatically shows you the bone that this attachment is, well, attached to. The model viewer will also show you where that attachment is placed.
I LOVE YOU SO MUCH THANK YOU