Raised This Month: $159 Target: $400
 39% 

Spawning a prop_physics and making it follow a player.


Post New Thread Reply   
 
Thread Tools Display Modes
chundo
Senior Member
Join Date: May 2008
Old 09-21-2008 , 21:17   Re: Spawning a prop_physics and making it follow a player.
Reply With Quote #11

Here's what I used to attach the party hat model to a player. "model" is the model path (I was using "models/effects/bday_hat.mdl"), and "target" is the player index to put it on:

Code:
    if (!IsModelPrecached(model))
        PrecacheModel(model);

    g_prop = CreateEntityByName("prop_dynamic_override");
    if (IsValidEntity(g_prop)) {
        SetVariantString("!activator");
        AcceptEntityInput(g_prop, "SetParent", target, g_prop, 0);
        SetVariantString("head");
        AcceptEntityInput(g_prop, "SetParentAttachment", g_prop, g_prop, 0);
        DispatchKeyValue(g_prop, "model", model);
        if (GetClientTeam(target) == 3)
            DispatchKeyValue(g_prop, "skin", "1");
        DispatchKeyValue(g_prop, "solid", "0");
        DispatchKeyValue(g_prop, "targetname", "potw_hat1");
        DispatchSpawn(g_prop);
        AcceptEntityInput(g_prop, "TurnOn", g_prop, g_prop, 0);
    }
The purpose was to force the player of the week to wear a party hat, but like I said, I couldn't work around the fact that the hat obstructed the player's view no matter what I did (try it and you'll see). If someone knows how to make it invisible to the player, please let me know.
__________________
chundo is offline
teddyruxpin
Overseer of lost packets
Join Date: Feb 2008
Old 09-21-2008 , 23:20   Re: Spawning a prop_physics and making it follow a player.
Reply With Quote #12

You may want to look at this plugin and see how SWAT_88 was able to do it with his parachute. I use this plugin on my hosts and never had an issue with it obstructing the views. It is however behind the player but could give you some ideas on how to make it work better for you.

http://forums.alliedmods.net/showthread.php?t=66452

-Teddy
__________________
Black Tusk Labs Home of Turbo TF2 and Turbo L4D:
http://blacktusklabs.com/ - Mah blog and stuff

My Crappy Plugins: SuperBuilds, Parent Buildables,
L4D Player Info
teddyruxpin is offline
Spazman0
Member
Join Date: Jul 2008
Old 09-22-2008 , 03:40   Re: Spawning a prop_physics and making it follow a player.
Reply With Quote #13

Ok, so it is the whole obstructing view thing. But also, when I spawn it it spawns infront of the player and stays in front of them as they walk around. Is there any way to offset the parent back a bit so that it's actually on their head? I believe if this can be done, it should also solve the obstructing view issue.

Last edited by Spazman0; 09-22-2008 at 03:54.
Spazman0 is offline
Spazman0
Member
Join Date: Jul 2008
Old 09-26-2008 , 22:06   Re: Spawning a prop_physics and making it follow a player.
Reply With Quote #14

Okay, I have figured out how to offset it and everything, the problem wasn't with offsetting, just my model wasn't in the centre of the grid. I am happy with how it is, although it still obstructs the player's view a little bit. Now the only problem I have is I don't know how to remove it when I toggle the command off them.

Any help?

EDIT: I have figured out how to remove it thankyou.

Now my new question (it's endless isn't it?)

Is there a way, so that if the model is parented to a player, it doesn't show up only for that player?

Last edited by Spazman0; 09-27-2008 at 10:00.
Spazman0 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:11.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode