Raised This Month: $12 Target: $400
 3% 

Spawning a prop_physics and making it follow a player.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Spazman0
Member
Join Date: Jul 2008
Old 09-18-2008 , 20:16   Spawning a prop_physics and making it follow a player.
Reply With Quote #1

I am currently in the process of making a command that spawns a custom model prop_physics above a players head and stays with them when they move. I have written all the foundations for the plugin, and now I just need to spawn the prop.

I am assuming I will need to use CreateEntityByName("prop_physics")(or prop_physics_multiplayer) but that's about as far as I have gotten.

So basically what I need is:

A way to spawn a prop_physics (or prop_physics_multiplayer) with a custom model
A way to make this prop follow the player.

Any help would be wonderful, thank you Allied Modders community.

Also, look for this command in the next release of FuncommandsX.

Spazman0.

Last edited by Spazman0; 09-19-2008 at 00:28.
Spazman0 is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 09-18-2008 , 22:14   Re: Spawning a prop_physics and parenting it to a player.
Reply With Quote #2

There should be a signature for CBaseSomething(Entity?)::SetParent somewhere.. I've seen it before.

You might have to do a bit of research.
__________________
Greyscale is offline
Kigen
BANNED
Join Date: Feb 2008
Old 09-18-2008 , 23:32   Re: Spawning a prop_physics and parenting it to a player.
Reply With Quote #3

That prop doesn't support being parented.

http://developer.valvesoftware.com/wiki/Prop_physics
Kigen is offline
Spazman0
Member
Join Date: Jul 2008
Old 09-19-2008 , 00:21   Re: Spawning a prop_physics and parenting it to a player.
Reply With Quote #4

Ok, so reading that article Kigen sent, I might be better off going with prop_physics_multiplayer. Still doesn't solve the issue of how to spawn it and make it follow the player. Any help?
Spazman0 is offline
Kigen
BANNED
Join Date: Feb 2008
Old 09-19-2008 , 01:27   Re: Spawning a prop_physics and making it follow a player.
Reply With Quote #5

Read the text I put above my link. I'm saying you CANNOT parent prop_physics.

Look at other props to see if one matches what your trying to do.

http://developer.valvesoftware.com/w...Types_Overview
Kigen is offline
Spazman0
Member
Join Date: Jul 2008
Old 09-19-2008 , 03:07   Re: Spawning a prop_physics and making it follow a player.
Reply With Quote #6

I read the whole article, and couldn't see anywhere that it can't be parented. Unless you are saying this from your own experience, in which case I apologize.

For the moment I am doing away with the parenting and just trying to spawn it. However, when I run the command my server pops up with a message saying: 292/ - prop_physics: UTIL_SetModel: not precached: models/Hat/model.mdl

This is the code I use to spawn the prop and give it the hat model:
PHP Code:
new Float:fPosition[3]
    
GetClientEyePosition(targetfPosition)
    new 
String:sModel[64]
    
sModel "models/Hat/model.mdl"
    
new iModel CreateEntityByName("prop_physics");
    
TeleportEntity(iModelfPositionNULL_VECTORNULL_VECTOR);
    
SetEntityModel(iModel,sModel); 
Any help would be great, thanks.

I am assuming that I have to somehow "precache" the model with the server? If so, how would I go about doing this?

I sv_pure is set to 0, just incase you were wondering.

Last edited by Spazman0; 09-19-2008 at 04:18.
Spazman0 is offline
Kigen
BANNED
Join Date: Feb 2008
Old 09-19-2008 , 13:00   Re: Spawning a prop_physics and making it follow a player.
Reply With Quote #7

Code:
native PrecacheModel(const String:model[], bool:preload=false);
Do it in OnMapStart().

Try prop_dynamic, since that can be parented.

http://developer.valvesoftware.com/wiki/Prop_dynamic
Kigen is offline
chundo
Senior Member
Join Date: May 2008
Old 09-20-2008 , 01:03   Re: Spawning a prop_physics and making it follow a player.
Reply With Quote #8

Actually you should use prop_dynamic_override, if I remember my experimentation correctly. I was trying to do exactly this. I gave up in the end - it always ended up obstructing the player's field of view, even if it looked like it shouldn't.
__________________
chundo is offline
Spazman0
Member
Join Date: Jul 2008
Old 09-20-2008 , 06:28   Re: Spawning a prop_physics and making it follow a player.
Reply With Quote #9

EDIT: Got it to work.


Now, I have it spawning as a prop_dynamic_override.

How would I go about parenting it to the player? (assuming the player is defined by "target")

At the moment this is my entire spawn code (Edited chundo's Achievement trophy code)

PHP Code:
new Float:fPosition[3]
    
GetClientEyePosition(targetfPosition)
    
fPosition[2]+=10
    
new String:sModel[64]
    
sModel "models/Hat/model.mdl"
    
new iModel CreateEntityByName("prop_dynamic_override");
    
TeleportEntity(iModelfPositionNULL_VECTORNULL_VECTOR);
    
DispatchKeyValue(iModel"model""models/Hat/model.mdl");
    
DispatchSpawn(iModel);
    
AcceptEntityInput(iModel"SetParent"targettarget0);
    
AcceptEntityInput(iModel"TurnOn"targettarget0); 

Last edited by Spazman0; 09-20-2008 at 07:37.
Spazman0 is offline
Spazman0
Member
Join Date: Jul 2008
Old 09-21-2008 , 20:02   Re: Spawning a prop_physics and making it follow a player.
Reply With Quote #10

Sorry to bump, but I wasn't sure people realised I have edited the last post with more details and a new request.
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 07:59.


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