Parenting to the player

Avatar
gallardo
85 Posts
Posted Jun 08, 2013
Hi there,
I have a func_brush attached to the player (parent, !player) and then a entity_maker attached to the brush (inherit dir is on).
Problem is that when I spawn an item, the direction is not always correct, especially when I turn not so fast and the aim stays off a bit.

What's I'm doing wrong?
Thanks

Advertisement
Registered users don’t see ads! Register now!
Avatar
ChickenMobile
2,460 Posts
Posted Jun 09, 2013
Replied 13 hours later
Is there any delay with spawning the item?

Technically any process is going to take more than 'immediately'.

Avatar
gallardo
85 Posts
Posted Jun 09, 2013
Replied 2 hours later
Sure, but it's not the case, since if you stop turning, the aim can remain off a bit anyway, then if you make a step forward or backward (no change of dir), it gets right.
Avatar
FelixGriffin
2,680 Posts
Posted Jun 09, 2013
Replied 4 hours later
If the player rotates without moving forwards, only the view changes. SetParentAttachmentMaintainOffset to eyes and it should be good, although if you don't want it to move up and down forward might be a better attachment point. I ran into this when I was building the shield from Bastion.
Avatar
gallardo
85 Posts
Posted Jun 09, 2013
Replied 33 minutes later
Yes, I need it just to rotate on 1 axis, so if the player raises the view the item is still spawned parallel to the ground.
I'll try what you suggested and report asap, thanks!
Avatar
gallardo
85 Posts
Posted Jun 09, 2013
Replied 45 minutes later
I've tried a bit but it doesn't seem to work.
SetParentAttachmentMaintainOffset to weapon_att should have been fine, but again it parents to the gun in thirdperson, not the one visible in firstperson :sad:
Looking at it in thirdperson I can see the parented brush turn perfectly (entity_maker is parented at it), but not the player model. I wonder how the brush is visually in line, but not the entity_maker...
Avatar
josepezdj
2,386 Posts
Posted Jun 11, 2013
Replied 1 day later
I'm not sure if what you need is to parent something to the gun or to the player... However, bare in mind that it's not that easy to parent something to the portalgun when the player already holds it; from this moment on, the portalgun becomes a 'viewmodel' and not a 'world model' anymore (and it's difficult to find its attachment points... at least for me, without scripting)... You can parent whatever to the portalgun before the player picks it up though and it will be still there parented after the player picked the gun up. I think this could be the better approach than the player 'eyes' attachment in order to avoid possible sudden player moves and such in the meantime before the parenting takes place.

As Felix said, I think that SetParentAttachmentMaintainOffset would be the best way to go... Why are you parenting a func_brush inbetween, before the entity maker? is it in order to give a proper orientation to the future spawned entity? ...Anyways, just: name the portalgun (you can disable its motion), name the func_brush and the entity maker, place the func_brush and entity maker at the distance you need to from the gun muzzle, add the portalgun name to the func_brush parent property, the func_brush name to the entity maker's Parent property, and then fire the outputs via a logic_auto:

- OnMapSpawn > [func_brush_name] > SetParent > [portalgun's name] / delay 0.10
- OnMapSpawn > [func_brush_name] > SetParentAttachmentMaintainOffset > [portalgun's name] / delay 0.10
- OnMapSpawn > [maker's name] > SetParent > [func_brush_name] / delay 0.20
- OnMapSpawn > [maker's name] > SetParentAttachmentMaintainOffset > [func_brush_name]
/ delay 0.20

It should work...

After that, you can teleport the gun to the player by using the target !player

Avatar
CamBen
973 Posts
Posted Jun 11, 2013
Replied 7 hours later
So then the func_brush will follow the movement of the portal gun?this could be useful to me as well.
Advertisement
Registered users don’t see ads! Register now!
Avatar
KathyGraham
1 Posts
Posted Jun 12, 2013
Replied 17 hours later
That's the best way for doing this, I have done this.