Parenting to Player

Avatar
Brainstatic
219 Posts
Posted Dec 16, 2011
Simple question; is it possible to parent an entity to the player's origin in single player? I tried using !player as the parent, which did not work. Parenting to the portal gun is perfectly possible, but I can't get the offset quite right to be exactly where the player is standing.
Advertisement
Registered users don’t see ads! Register now!
Avatar
Skotty
671 Posts
Posted Dec 16, 2011
Replied 1 hour later
Use player for the player. !Player is just for outputs, but the player istelf is names player (developer 2; ent_text player and you will see a text under your with all your parameters).
Avatar
Robdon
204 Posts
Posted Dec 16, 2011
Replied 6 minutes later
Hi,

You could try this...

If you create a trigger_once and say a brush called 'box1', and then on trigger do a 'box1:SetParent:!activator', that will parent it to the player.

That does it somewhat, but if you go too close to any objects it disappears 'into' the object if you get too close.

The item will also disappear if you go upto and through a portal, and then it reappears when you're through the other side.

Suppose, depending on what you wanna do, that could help you?

Rob.

Avatar
Brainstatic
219 Posts
Posted Dec 16, 2011
Replied 6 minutes later

Skotty wrote:
Use player for the player. !Player is just for outputs...

Ah, okay. So much more makes sense now! Thank you.

Robdon wrote:
Hi,

You could try this...

If you create a trigger_once and say a brush called 'box1', and then on trigger do a 'box1:SetParent:!activator', that will parent it to the player.

Now that I know that parenting objects to players is possible, I will try that as well. Your method will help with dynamically setting the parent for some invisible entities like info_targets in the entity setup I'm trying to use, so thank you as well.

Avatar
CaretCaret
290 Posts
Posted Dec 16, 2011
Replied 53 minutes later
I think I had an logic_auto parent an object to !player onmapspawn.
Avatar
Lpfreaky90
2,842 Posts
Posted Dec 17, 2011
Replied 19 hours later
I've got another question: I want an object to teleport to my position if it was dropped, with a delay of 10 seconds. What I got is:

Object to pick up:
OnPlayerPickup pickup_trigger trigger
OnPlayerDrop drop_trigger trigger
OnUser2: -> The actual teleport.

pickup_trigger:
OnTrigger drop_trigger cancelpending

drop_trigger:
OnTrigger drop_thing fireuser2

But I have no idea how to teleport that thing to my position. What I tried:
using point_teleport:
Logic auto, onmapspawn point_teleport setparent !player
Logic auto, onmapspawn point_teleport setparent player

Both cases didn't move the point_player so the object was dropped back were I started.
A trigger_brush with onStarttouch point_teleport, SetParent !activator
A trigger_brush with onStarttouch point_teleport, SetParent !player
A trigger_brush with onStarttouch point_teleport, SetParent player

Soo... that also didn't work

Now I tried a trigger_teleport, parented to my object. with object
OnUser2 trigger_teleport enable 0.00
OnUser2 trigger_teleport disable 0.30 with the the remote destination to a parented info_target, but this does absolutely nothing.

Anyone suggestions? :biggrin:

Avatar
reepblue
894 Posts
Posted Dec 17, 2011
Replied 5 minutes later

lpfreaky90 wrote:
I've got another question: I want an object to teleport to my position if it was dropped, with a delay of 10 seconds. What I got is:

Object to pick up:
OnPlayerPickup pickup_trigger trigger
OnPlayerDrop drop_trigger trigger
OnUser2: -> The actual teleport.

pickup_trigger:
OnTrigger drop_trigger cancelpending

drop_trigger:
OnTrigger drop_thing fireuser2

But I have no idea how to teleport that thing to my position. What I tried:
using point_teleport:
Logic auto, onmapspawn point_teleport setparent !player
Logic auto, onmapspawn point_teleport setparent player

Both cases didn't move the point_player so the object was dropped back were I started.
A trigger_brush with onStarttouch point_teleport, SetParent !activator
A trigger_brush with onStarttouch point_teleport, SetParent !player
A trigger_brush with onStarttouch point_teleport, SetParent player

Soo... that also didn't work

Now I tried a trigger_teleport, parented to my object. with object
OnUser2 trigger_teleport enable 0.00
OnUser2 trigger_teleport disable 0.30 with the the remote destination to a parented info_target, but this does absolutely nothing.

Anyone suggestions? :biggrin:

Try using point_teleport instead of triggers.

Avatar
Lpfreaky90
2,842 Posts
Posted Dec 17, 2011
Replied 3 minutes later
I tried point_teleport and that teleported my entity properly.
The only problem was that for some reason my point_teleport wouldn't parent to the player.

The ways I tried were:
Logic auto, onmapspawn point_teleport setparent !player
Logic auto, onmapspawn point_teleport setparent player
A trigger_once with onStarttouch point_teleport, SetParent !activator
A trigger_once with onStarttouch point_teleport, SetParent !player
A trigger_once with onStarttouch point_teleport, SetParent player

Avatar
Brainstatic
219 Posts
Posted Dec 17, 2011
Replied 1 hour later
I'm actually doing something remotely similar, in which a cube and the player switch places on a button press. If I'm not mistaken, point_teleport cannot be parented. To "teleport" the cube, I actually make the cube silentdissolve, then respawn it at the player's position using a point_template and an env_entity_maker.

It's a little bit more complicated than that since certain entities have to be left behind by both the player and the cube prior to the teleports, but that's the basic idea: try a point_template and env_entity_maker. The only issue, however, is that the point_template seems to remember the cube's state only from when it first spawned. So if it gets painted, the paint will disappear after a teleport. I'm trying to work that issue out now.

Avatar
ChickenMobile
2,460 Posts
Posted Dec 17, 2011
Replied 6 hours later
A point_teleport teleports an object to a certain spot (i.e. to an info_target) from an output. I don't see why you would need to parent the point_teleport whatsoever.

Refer to this picture:
picture
img

Avatar
Lpfreaky90
2,842 Posts
Posted Dec 17, 2011
Replied 15 minutes later

chickenmobile wrote:
A point_teleport teleports an object to a certain spot (i.e. to an info_target) from an output. I don't see why you would need to parent the point_teleport whatsoever.

Refer to this picture:
picture
img

The problem is that I want an ontrigger -> object teleport to player. That is why there is something that has to be target to the player, since the point where the object has to teleport is different.

Avatar
Brainstatic
219 Posts
Posted Dec 18, 2011
Replied 14 hours later

chickenmobile wrote:
A point_teleport teleports an object to a certain spot (i.e. to an info_target) from an output. I don't see why you would need to parent the point_teleport whatsoever.

Refer to this picture:
picture
img

You should start a site with Hammer tutorials all in picture form like that. But I just tested a point_teleport, and I could not get it to teleport any entities to any location other than that of the point_teleport.

The Teleport input teleports the entity to teleport (the one in the keyvalues) to the location of the point_teleport.
The TeleportToCurrentPos input seems to do the same thing.
The TeleportEntity input, the only of these three that has a parameter, teleports the entity that is placed in the parameter override to the location of the point_teleport.

Specifically, how would I use a point_teleport to teleport an entity to a mobile position?

Avatar
ChickenMobile
2,460 Posts
Posted Dec 18, 2011
Replied 7 hours later

Last night I wrote a whole paragraph that seemed to not have posted... anyway...

I was going to say it would be better to actually use scripting instead of a point_teleport in order to teleport the info_target to the player then parent it. Insert entity scripts inside your info_target which you want the object to teleport to and then on an output, make it activate the script which will parent the info_target to the player, like so:

imgimg

function TeleportToPlayer()
{
   self.SetOrigin(player.GetCenter())
   EntFire( self.GetName(), "SetParent", "!player", 0, 0)
}

How about I make it easier for you by giving you the example I made :razz:

tpToPlayer.zip
Attachments
tpToPlayer.zip
0.00 MB 55 downloads
Advertisement
Registered users don’t see ads! Register now!
Avatar
Brainstatic
219 Posts
Posted Dec 18, 2011
Replied 1 hour later

chickenmobile wrote:
How about I make it easier for you by giving you the example I made :razz:

Thank you very much! :notworthy: