Hi all.
Im attempting to parent a prop_dynamic_override to a player (CS:S).
I have somewhat successfully done that with the code below:
PHP Code:
GiveLunchTray(index)
{
if(lunchTrayIds[index] != 0) return
new ent = CreateEntityByName("prop_dynamic_override");
SetEntityModel(ent, MDL_LUNCHTRYA);
new Float:angles[3], Float:origin[3], Float:trayPos[3]
GetClientAbsOrigin(index, origin)
GetEntPropVector(index, Prop_Data, "m_angAbsRotation", angles)
trayPos[2] = origin[2] + 40.0
trayPos[0] = Cosine(DegToRad(angles[1])) * 50.0 + origin[0]
trayPos[1] = Sine(DegToRad(angles[1])) * 50.0 + origin[1]
DispatchSpawn(ent)
TeleportEntity(ent, trayPos, angles, NULL_VECTOR)
//SetEntProp(ent, Prop_Data, "m_iParent", index)
SetVariantString("!activator");
AcceptEntityInput(ent, "SetParent", index, ent, 0);
lunchTrayIds[index] = ent
}
However there is an undesired effect. When the player looks around, the prop rotates around the origin of the player (i.e, the players feet).
I simply want to parent the prop to the players model, not the players vision.
Is there a way to do this that im missing?
Any help is appreciated
Thanks in advanced