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

Solved [CSGO] How to attach/parent models correctly


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 10-29-2017 , 05:57   [CSGO] How to attach/parent models correctly
Reply With Quote #1

I converted some cs 1.6 models to CSGO for my Zombie Project and i have issues with attach/parent a submodel:

Code used:
https://forums.alliedmods.net/showpo...73&postcount=2
PHP Code:
stock int SpawnModelAndAttach(int Clientchar[] StrModelchar[] StrAttachmentfloat Offset[3])
{
    
// Precache model
    
PrecacheModel(StrModeltrue);
    
    
// Generate unique id for the client so we can set the parenting
    // through parentname.
    
char StrName[64]; Format(StrNamesizeof(StrName), "Client%i"Client);
    
DispatchKeyValue(Client"targetname"StrName);
    
    
// Spawn dynamic prop entity
    
int Entity CreateEntityByName("prop_dynamic");
    if (
Entity == -1) return -1;
    
    
// Generate unique id for the entity
    
char StrEntityName[64]; Format(StrEntityNamesizeof(StrEntityName), "prop_dynamic_%i"Entity);
    
    
// Setup entity
    
DispatchKeyValue(Entity"targetname"StrEntityName);
    
DispatchKeyValue(Entity"parentname"StrName);
    
DispatchKeyValue(Entity"model",      StrModel);
    
DispatchKeyValue(Entity"solid",      "0");
    
SetEntityModel(EntityStrModel);
    
DispatchSpawn(Entity);
    
    
// Determine position for the model
    
float Position[3]; GetClientAbsOrigin(ClientPosition);
    
Position[0] += Offset[0];
    
Position[1] += Offset[1];
    
Position[2] += Offset[2];
    
TeleportEntity(EntityPositionNULL_VECTORNULL_VECTOR);
    
    
// Set parent
    
SetVariantString(StrName);
    
AcceptEntityInput(Entity"SetParent"EntityEntity0);
    
    
// Set attachment if possible
    
if (StrEqual(StrAttachment"") == false)
    {
        
SetVariantString(StrAttachment);
        
AcceptEntityInput(Entity"SetParentAttachment"EntityEntity0);
    }
    
    
// Activate
    
AcceptEntityInput(Entity"TurnOn");
    
    
// Done
    
return Entity;

Converted Model on SDK Model Viewer:



Converted Model In Game Spawned:



Anyone can help with this?

I'm going to distribute this model to anyone who wants to use it too.

Regards.
__________________
My Plugins | VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet

CZSBrasil TEAM

Last edited by rodrigo286; 11-02-2017 at 16:43.
rodrigo286 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 10-29-2017 , 11:58   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #2

try attach to the c4 attachement

PHP Code:
SetVariantString("c4");
AcceptEntityInput(Entity"SetParentAttachmentMaintainOffset"EntityEntity0); 
__________________
8guawong is offline
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 10-29-2017 , 13:13   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #3

Thanks but dont work, i try c4, defusekit, spine_02, ValveBiped.Bip01_Spine, ValveBiped.Bip01_Spine1, ValveBiped.Bip01_Spine2 and ValveBiped.Bip01_Spine3...

I'will try more ways.

PHP Code:
stock int SpawnModelAndAttach(int Clientchar[] StrModelfloat Offset[3])
{
    
// Precache model
    
PrecacheModel(StrModeltrue);

    
// Generate unique id for the client so we can set the parenting
    // through parentname.
    
char StrName[64]; Format(StrNamesizeof(StrName), "Client%i"Client);
    
DispatchKeyValue(Client"targetname"StrName);

    
// Spawn dynamic prop entity
    
int Entity CreateEntityByName("prop_dynamic");
    if (
Entity == -1) return -1;

    
// Generate unique id for the entity
    
char StrEntityName[64]; Format(StrEntityNamesizeof(StrEntityName), "prop_dynamic_%i"Entity);

    
// Setup entity
    
DispatchKeyValue(Entity"targetname"StrEntityName);
    
DispatchKeyValue(Entity"parentname"StrName);
    
DispatchKeyValue(Entity"model",      StrModel);
    
DispatchKeyValue(Entity"solid",      "0");
    
SetEntityModel(EntityStrModel);
    
DispatchSpawn(Entity);

    
// Determine position for the model
    
float Position[3]; GetClientAbsOrigin(ClientPosition);
    
Position[0] += Offset[0];
    
Position[1] += Offset[1];
    
Position[2] += Offset[2];
    
TeleportEntity(EntityPositionNULL_VECTORNULL_VECTOR);

    
// Set parent
    
SetVariantString(StrName);
    
AcceptEntityInput(Entity"SetParent"EntityEntity0);

    
SetVariantString("c4");
    
AcceptEntityInput(entjetpack[Client], "SetParentAttachmentMaintainOffset"entjetpack[Client], entjetpack[Client], 0);

    
// Set attachment if possible

    // Activate
    
AcceptEntityInput(Entity"TurnOn");

    
// Done
    
return Entity;

Thanks.
__________________
My Plugins | VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet

CZSBrasil TEAM
rodrigo286 is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 10-29-2017 , 14:16   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #4

Try something like this:
Quote:
float Position[3];
GetClientAbsOrigin(client,lPosition);
Position[0] -= 0;
Position[1] -= 0;
Position[2] += 90;

TeleportEntity(Entity,Position,NULL_VECTOR,NU LL_VECTOR);
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<

Last edited by andi67; 10-29-2017 at 14:17.
andi67 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 10-29-2017 , 14:26   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #5

if you share the model i might try to do some testing myself
__________________

Last edited by 8guawong; 10-29-2017 at 14:26.
8guawong is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-29-2017 , 15:14   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #6

is that player model default or custom one ?

*edit anyway
You need delay by frame after teleport and after setparent
https://developer.valvesoftware.com/...MaintainOffset

*edit
Be sure after you have teleported your prop, it have right angle
__________________
Do not Private Message @me

Last edited by Bacardi; 10-29-2017 at 15:19.
Bacardi is offline
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 10-29-2017 , 16:26   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #7

Quote:
Originally Posted by andi67 View Post
Try something like this:
Thanks, but now model spawned some meters above of players head

Quote:
Originally Posted by 8guawong View Post
if you share the model i might try to do some testing myself
Download link below, have two models jetpack only and jetpack + egon weapon:



I will covert Black Mesa Source version also.

Thanks for all help.

Quote:
Originally Posted by Bacardi View Post
is that player model default or custom one ?

*edit anyway
You need delay by frame after teleport and after setparent
https://developer.valvesoftware.com/...MaintainOffset

*edit
Be sure after you have teleported your prop, it have right angle
I need teleport using OnGameFrame?

Is custom models

Thanks for help.
__________________
My Plugins | VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet

CZSBrasil TEAM

Last edited by rodrigo286; 10-29-2017 at 16:42.
rodrigo286 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-29-2017 , 18:02   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #8

Quote:
Originally Posted by rodrigo286 View Post
...
I need teleport using OnGameFrame?
...
No. I didn't say that.
RequestFrame for one frame delays. Or use timer with 0.0 sec.
__________________
Do not Private Message @me
Bacardi is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 10-29-2017 , 18:07   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #9

What I meant is you can adjust the position with this , you can also rotate your model in the qc and recompile...
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is offline
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 10-29-2017 , 18:47   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #10

Quote:
Originally Posted by Bacardi View Post
No. I didn't say that.
RequestFrame for one frame delays. Or use timer with 0.0 sec.
I need teleportentity every 0.0 seconds for new pos, i will try it.

Quote:
Originally Posted by andi67 View Post
What I meant is you can adjust the position with this , you can also rotate your model in the qc and recompile...
Dont work, some times model spawn in right or left...

Regards.
__________________
My Plugins | VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet

CZSBrasil TEAM
rodrigo286 is offline
Reply



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 08:41.


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