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

Solved [CSGO] How to attach/parent models correctly


Post New Thread Reply   
 
Thread Tools Display Modes
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 10-29-2017 , 20:37   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #11

Quote:
Originally Posted by Bacardi View Post
timer with 0.0 sec.
IIRC the lowest float value the function CreateTimer accepts is 0.1
__________________
xines is offline
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 10-30-2017 , 04:13   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #12

Same problem, i added delay on all parent querys, spawn ent and dont work:

PHP Code:
void EquipJetpackModel(int client)
{
    if(!
IsValidAndAliveClient(client))
        return;

    
// 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);

    
// Create the hat entity
    
entjetpack[client] = CreateEntityByName("prop_dynamic");

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

    
// Setup entity
    
DispatchKeyValue(entjetpack[client], "targetname"StrEntityName);
    
DispatchKeyValue(entjetpack[client], "parentname"StrName);
    
DispatchKeyValue(entjetpack[client], "model"MDL_JETPACK);
    
DispatchKeyValue(entjetpack[client], "solid""0");
    
DispatchKeyValue(entjetpack[client], "spawnflags""256");
    
SetEntPropEnt(entjetpack[client], Prop_Send"m_hOwnerEntity"client);
    
SetEntityMoveType(entjetpack[client], MOVETYPE_NOCLIP);

    
// Create blank position vector and Determine position for the model
    
float pos[3]; GetClientAbsOrigin(clientpos);
    
pos[0] += 0.0;
    
pos[1] += 0.0;
    
pos[2] += 0.0;
    
TeleportEntity(entjetpack[client], posNULL_VECTORNULL_VECTOR);

    
// Set parent
    
SetVariantString(StrName);
    
AcceptEntityInput(entjetpack[client], "SetParent"entjetpack[client], entjetpack[client], 0);

    
// Timer to set attachment
    
DataPack Spawn;
    
CreateDataTimer(0.1spawnEntSpawn);
    
Spawn.WriteCell(client);
}

public 
Action spawnEnt(Handle timerDataPack Spawn)
{
    
int client;
    
ResetPack(Spawnfalse);
    
client ReadPackCell(Spawn);
    if (
IsValidAndAliveClient(client)){
        
// Spawn Jetpack Model Prop
        
DispatchSpawn(entjetpack[client]);
        
// Timer to set attachment
        
DataPack pAttach;
        
CreateDataTimer(0.1parentAttachpAttach);
        
pAttach.WriteCell(client);
    }
}

public 
Action parentAttach(Handle timerDataPack pAttach)
{
    
int client;
    
ResetPack(pAttachfalse);
    
client ReadPackCell(pAttach);
    if (
IsValidAndAliveClient(client)){
        
// Set attachment
        
SetVariantString("forward");
        
AcceptEntityInput(entjetpack[client], "SetParentAttachment"entjetpack[client], entjetpack[client], 0);
        
// Timer to set attachment offset
        
DataPack pAttachOffset;
        
CreateDataTimer(0.1parentAttachOffsetpAttachOffset);
        
pAttachOffset.WriteCell(client);
    }
}

public 
Action parentAttachOffset(Handle timerDataPack pAttachOffset)
{
    
int client;
    
ResetPack(pAttachOffsetfalse);
    
client ReadPackCell(pAttachOffset);
    if (
IsValidAndAliveClient(client)){
        
// Set attachment offset "spine_1" for custom player models
        
SetVariantString("forward");
        
AcceptEntityInput(entjetpack[client], "SetParentAttachmentMaintainOffset"entjetpack[client], entjetpack[client], 0); 
        
AcceptEntityInput(entjetpack[client], "TurnOn");
    }

Finaly i add this line:

PHP Code:
DispatchKeyValue(entjetpack[client], "angles""0 -90 0"); 
After this model spawn on correct location but appear dont follow rotation and player model sequence, any way to fix this?

Thanks for all help friends.
__________________
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
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-30-2017 , 10:28   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #13

I have deja vu that... attachment "forward" is either disabled, or it will not work anyway. Maybe it not use any animation etc. etc.
Code:
ERROR: Tried to SetParentAttachmentMaintainOffset for entity prop_dynamic (shot), but it has no attachment named forward.
If you like your model to follow player animation, you need use another attachment name. example, primary.


But, I have feeling that your compiled model origin/offset is way too out of jetpack, this give you problems.
(Unless, you want simply model to follow player than follow player animations, then you need just "SetParent" action.)








Can you show QC file ?
Attached Images
File Type: jpg Untitled.jpg (94.6 KB, 801 views)
__________________
Do not Private Message @me

Last edited by Bacardi; 10-30-2017 at 10:36.
Bacardi is offline
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 10-30-2017 , 11:24   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #14

Quote:
Originally Posted by Bacardi View Post
I have deja vu that... attachment "forward" is either disabled, or it will not work anyway. Maybe it not use any animation etc. etc.
Code:
ERROR: Tried to SetParentAttachmentMaintainOffset for entity prop_dynamic (shot), but it has no attachment named forward.
If you like your model to follow player animation, you need use another attachment name. example, primary.


But, I have feeling that your compiled model origin/offset is way too out of jetpack, this give you problems.
(Unless, you want simply model to follow player than follow player animations, then you need just "SetParent" action.)








Can you show QC file ?
Thanks for help, uploaded to post .qc and all project files zipped.
Attached Files
File Type: zip jetpack.zip (16.8 KB, 103 views)
File Type: txt jetpack.qc.txt (423 Bytes, 216 views)
__________________
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
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-30-2017 , 13:20   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #15

dam, I need practise modeling .P
Could I success with blender...
Bacardi is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 10-30-2017 , 15:41   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #16

Quote:
ERROR: Tried to SetParentAttachmentMaintainOffset for entity prop_dynamic (shot), but it has no attachment named forward.
New models don´t have that attachmentpoint , try a valid one like "c4"(spine_3)......"

List:
Quote:
"legacy_weapon_bone" "ValveBiped.weapon_bone"
"weapon_hand_L" "weapon_hand_L"
"weapon_hand_R" "weapon_hand_R"
"primary" "primary_jiggle_jnt"
"pistol" "leg_upper_R"
"knife" "leg_upper_L"
"eholster" "leg_upper_L"
"grenade0" "spine_0"
"grenade1" "spine_0"
"grenade2" "spine_0"
"grenade3" "spine_0"
"grenade4" "spine_0"
"defusekit" "spine_0"
"c4" "spine_3"
"facemask" "head_0"
"clip_limit" "head_0"
"primary_smg" "primary_smg_jiggle_jnt"
__________________
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-30-2017 at 15:46.
andi67 is offline
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 10-30-2017 , 19:03   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #17

#EDIT

Sorry for double post...

i dont undertand...

In .qc file:

PHP Code:
$CBox 0 0 0 0 0 0

$BBox 0 0 0 0 0 0

$HBox 0 
"spine_2" -10.28 -16.540001 -11.06 17.950001 0 9.7

$attachment 
"defusekit" "spine_2" -1.60 -5.50 0.00 rotate -0 90 90

$attachment 
"c4" "spine_2" 2.00 -6.00 2.70 rotate 4 4 85 
PHP Code:
$ModelName "rodrigo286\jetpack\nuclear_jetpack.mdl" //name model

$CDMaterials "models\rodrigo286\nuclear_jetpack\" //textures

$BodyGroup "studio"
{
    studio "
nuclear_jetpack_reference.smd"
}

$SurfaceProp "metal"

$Contents "solid"

$MaxEyeDeflection 90

$CBox 0 0 0 0 0 0

$BBox 0 0 0 0 0 0

$HBox 0 "spine_2" -10.28 -16.540001 -11.06 17.950001 0 9.7

$attachment "defusekit" "spine_2" -1.60 -5.50 0.00 rotate -0 90 90

$attachment "c4" "spine_2" 2.00 -6.00 2.70 rotate 4 4 85

$Sequence "idle" {
    "
nuclear_jetpack_anims\idle.smd"
    fadein 0.2
    fadeout 0.2
    fps 30
    loop
}

$CollisionModel "nuclear_jetpack_physics.smd"
{
    
$mass 25
    
$inertia 1
    
$damping 0
    
$rotdamping 0
    
$concave


On Model Viewer:





In .sp:

PHP Code:
public Action parentAttach(Handle timerDataPack pAttach)
{
    
int client;
    
ResetPack(pAttachfalse);
    
client ReadPackCell(pAttach);
    if (
IsValidAndAliveClient(client)){
        
// Set attachment
        
SetVariantString("c4");
        
AcceptEntityInput(entjetpack[client], "SetParentAttachment"entjetpack[client], entjetpack[client], 0);
        
// Timer to set attachment offset
        
DataPack pAttachOffset;
        
CreateDataTimer(0.1parentAttachOffsetpAttachOffset);
        
pAttachOffset.WriteCell(client);
    }
}

public 
Action parentAttachOffset(Handle timerDataPack pAttachOffset)
{
    
int client;
    
ResetPack(pAttachOffsetfalse);
    
client ReadPackCell(pAttachOffset);
    if (
IsValidAndAliveClient(client)){
        
// Set attachment offset for custom player models
        
SetVariantString("c4");
        
AcceptEntityInput(entjetpack[client], "SetParentAttachmentMaintainOffset"entjetpack[client], entjetpack[client], 0); 
        
AcceptEntityInput(entjetpack[client], "TurnOn");
    }

PHP Code:
void EquipJetpackModel(int client)
{
    if(!
IsValidAndAliveClient(client))
        return;

    
// 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);

    
// Create the hat entity
    
entjetpack[client] = CreateEntityByName("prop_dynamic");

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

    
// Setup entity
    
DispatchKeyValue(entjetpack[client], "targetname"StrEntityName);
    
DispatchKeyValue(entjetpack[client], "parentname"StrName);
    
DispatchKeyValue(entjetpack[client], "model"MDL_JETPACK);
    
DispatchKeyValue(entjetpack[client], "solid""0");
    
DispatchKeyValue(entjetpack[client], "spawnflags""256");
    
DispatchKeyValue(entjetpack[client], "angles""0 0 0");
    
SetEntPropEnt(entjetpack[client], Prop_Send"m_hOwnerEntity"client);
    
SetEntityMoveType(entjetpack[client], MOVETYPE_NOCLIP);

    
// Create blank position vector and Determine position for the model
    
float pos[3]; GetClientAbsOrigin(clientpos);
    
pos[0] += 0.0;
    
pos[1] += 0.0;
    
pos[2] += 0.0;
    
TeleportEntity(entjetpack[client], posNULL_VECTORNULL_VECTOR);

    
// Set parent
    
SetVariantString(StrName);
    
AcceptEntityInput(entjetpack[client], "SetParent"entjetpack[client], entjetpack[client], 0);

    
// Timer to set attachment
    
DataPack Spawn;
    
CreateDataTimer(0.1spawnEntSpawn);
    
Spawn.WriteCell(client);
}

public 
Action spawnEnt(Handle timerDataPack Spawn)
{
    
int client;
    
ResetPack(Spawnfalse);
    
client ReadPackCell(Spawn);
    if (
IsValidAndAliveClient(client)){
        
// Spawn Jetpack Model Prop
        
DispatchSpawn(entjetpack[client]);
        
// Timer to set attachment
        
DataPack pAttach;
        
CreateDataTimer(0.1parentAttachpAttach);
        
pAttach.WriteCell(client);
    }
}

public 
Action parentAttach(Handle timerDataPack pAttach)
{
    
int client;
    
ResetPack(pAttachfalse);
    
client ReadPackCell(pAttach);
    if (
IsValidAndAliveClient(client)){
        
// Set attachment
        
SetVariantString("c4");
        
AcceptEntityInput(entjetpack[client], "SetParentAttachment"entjetpack[client], entjetpack[client], 0);
        
// Timer to set attachment offset
        
DataPack pAttachOffset;
        
CreateDataTimer(0.1parentAttachOffsetpAttachOffset);
        
pAttachOffset.WriteCell(client);
    }
}

public 
Action parentAttachOffset(Handle timerDataPack pAttachOffset)
{
    
int client;
    
ResetPack(pAttachOffsetfalse);
    
client ReadPackCell(pAttachOffset);
    if (
IsValidAndAliveClient(client)){
        
// Set attachment offset for custom player models
        
SetVariantString("c4");
        
AcceptEntityInput(entjetpack[client], "SetParentAttachmentMaintainOffset"entjetpack[client], entjetpack[client], 0); 
        
AcceptEntityInput(entjetpack[client], "TurnOn");
    }

But fail on game...



What i do wrong?

Thanks for all 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-30-2017 at 19:05.
rodrigo286 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-30-2017 , 23:08   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #18

Try replace SetParentAttachmentMaintainOffset
to
SetParentAttachment

Then you not need to teleport model in exactly place and angle in plugin source code.
It use model attachment position how you have made in qc file.

...I don't have time to look it now
__________________
Do not Private Message @me

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

Quote:
Originally Posted by Bacardi View Post
Try replace SetParentAttachmentMaintainOffset
to
SetParentAttachment

Then you not need to teleport model in exactly place and angle in plugin source code.
It use model attachment position how you have made in qc file.

...I don't have time to look it now
But i already have SetParentAttachment.

I need use only one?

PHP Code:
public Action parentAttach(Handle timerDataPack pAttach

    
int client
    
ResetPack(pAttachfalse); 
    
client ReadPackCell(pAttach); 
    if (
IsValidAndAliveClient(client)){ 
        
// Set attachment 
        
SetVariantString("c4"); 
        
AcceptEntityInput(entjetpack[client], "SetParentAttachment"entjetpack[client], entjetpack[client], 0); 
        
// Timer to set attachment offset 
        
DataPack pAttachOffset
        
CreateDataTimer(0.1parentAttachOffsetpAttachOffset); 
        
pAttachOffset.WriteCell(client); 
    } 


public 
Action parentAttachOffset(Handle timerDataPack pAttachOffset

    
int client
    
ResetPack(pAttachOffsetfalse); 
    
client ReadPackCell(pAttachOffset); 
    if (
IsValidAndAliveClient(client)){ 
        
// Set attachment offset for custom player models 
        
SetVariantString("c4"); 
        
AcceptEntityInput(entjetpack[client], "SetParentAttachmentMaintainOffset"entjetpack[client], entjetpack[client], 0);  
        
AcceptEntityInput(entjetpack[client], "TurnOn"); 
    } 

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-30-2017 at 23:41.
rodrigo286 is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 10-30-2017 , 23:47   Re: [CSGO] How to attach/parent models correctly
Reply With Quote #20

Try this, i use it in my L4D2 backpack plugin.

SetVariantString("!activator");
AcceptEntityInput(entity, "SetParent", client);

SetVariantString("medkit");
//AcceptEntityInput(entity, "SetParentAttachment", entity);
AcceptEntityInput(entity, "SetParentAttachmentMaintainOffset");

float Pos[3];
SetVector(Pos, 4.0, 2.0, 3.3); //SetVector(Pos, In/Out, Up/Down, Left/Right);

float Ang[3];
SetVector(Ang, 175.0, 85.0, -75.0);

TeleportEntity(entity, Pos, Ang, NULL_VECTOR);

void SetVector(float target[3], float x, float y, float z)
{
target[0] = x, target[1] = y, target[2] = z;
}

From my experiences with attaching models you will always need to set the angle manually, which from what I can tell your not setting it at all or your setting it with dispatchkeyvalue "angles" to 0 0 0, which in most instances won't come out right depending on the 0 0 0 position of the angles for the attachmentpoint, so yes its a little tedious but use an attachment point close to the original position of where you want the model on the players backs and trial and error test manually adjusting the angles with what i showed you. It should work. I've done this many times in L4D2 with having odd angles after attaching the models. So setting the pos and ang should do it.

You can probably use dispatchkeyvalue "angles" or whatever it is to set the angles instead too, given if that keyvalue actually exists in csgo. good luck...

Last edited by MasterMind420; 10-31-2017 at 01:06.
MasterMind420 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 13:21.


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