Raised This Month: $81 Target: $400
 20% 

[L4D2] predicted_viewmodel can't set attach to other entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LinLinLin
Senior Member
Join Date: Sep 2021
Old 11-27-2023 , 01:37   [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #1

code below:
PHP Code:
int entity CreateEntityByName("predicted_viewmodel");
if( 
entity || !IsValidEntity(entity) )
    return ;
SetEntPropEnt(entityProp_Send"m_hOwner"client);
SetEntPropEnt(entityProp_Send"m_hWeapon"weapon);
SetEntityModel(entityRIOTSHIELD_V);
ActivateEntity(entity);
SetVariantString("!activator");
AcceptEntityInput(entity"SetParent"targetentity);
SetVariantString("!activator");
AcceptEntityInput(entity"SetAttached"targetentity);
DispatchSpawn(entity); 
by use cl_pdump to check entity, it still fix in (0.0.0) pos in the world and never follow the targetentity.
is the code got some mistake or just the predicted_viewmodel enttiy can't be attached to other entity?
LinLinLin is online now
101
Member
Join Date: Nov 2023
Old 11-27-2023 , 03:33   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #2

[ANY] WeaponModels - Change any weapon model .

have a look :
https://github.com/Andersso/SM-WeaponModels
Attached Files
File Type: zip SM-WeaponModels.zip (39.2 KB, 35 views)
101 is offline
LinLinLin
Senior Member
Join Date: Sep 2021
Old 11-27-2023 , 03:45   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #3

thanks, but i don't need to change the model of weapon.
i need another predicted_viewmodel to follow player view to do other job.
LinLinLin is online now
101
Member
Join Date: Nov 2023
Old 11-27-2023 , 03:57   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #4

Quote:
Originally Posted by LinLinLin View Post
thanks, but i don't need to change the model of weapon.
i need another predicted_viewmodel to follow player view to do other job.
Forget the weapons ,the code just shows how to setup <predicted_viewmodel> Entity correctly without missing any part , i thought that was ur problem ;)
101 is offline
LinLinLin
Senior Member
Join Date: Sep 2021
Old 11-27-2023 , 04:06   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #5

I create the entity successfully but it doesn't attach to the entity i want. So i am not sure the attach code is worked.
LinLinLin is online now
101
Member
Join Date: Nov 2023
Old 11-28-2023 , 00:59   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #6

the entity may not be attachable to another entity!
but i have noticed FollowEntity() in V-developer with predicted_viewmodel like :

PHP Code:
void CEntHost::CreateViewModelint index )
{
    
AssertIsPlayer() );
    
Assertindex >= && index MAX_VIEWMODELS );

    if ( !
IsPlayer() )
        return;

    if ( 
GetPlayer()->GetViewModelindex ) )
        return;

    
CPredictedViewModel *vm = (CPredictedViewModel *)CreateEntityByName"predicted_viewmodel" );

    if ( 
vm ) {
        
vm->SetAbsOriginGetAbsOrigin() );
        
vm->SetOwnerGetPlayer() );
        
vm->SetIndexindex );

        
DispatchSpawnvm );
        
vm->FollowEntityGetPlayer(), false ); //Your Problem Is Here 
        
vm->AddEffectsEF_NODRAW );

        
GetPlayer()->m_hViewModel.Setindexvm );
    }

So This may help :

Quote:
Re: Entity Parenting detection
Success Code for others:
Code:
new childEntity = GetEntPropEnt(targetEntity, Prop_Data, "m_hMoveChild");
new parentEntity = GetEntPropEnt(targetEntity, Prop_Data, "m_hMoveParent");
if -1 means no entity found
otherwise true
Quote:
Re: Actually you can check if you successfully attached entity for some attachment
PHP Code:
bool AttachEntityint entityint owner, const char[] attachment NULL_STRING )
{    
    
SetVariantString("!activator");
    
AcceptEntityInput(entity"SetParent"owner);
    
    if (!
IsNullString(attachment))
    {
        
SetVariantString(attachment);
        
AcceptEntityInput(entity"SetParentAttachMent"owner);
        
        if ( 
GetEntProp(entityProp_Data"m_iParentAttachment") == )
        {
            
LogError("Failed to set attachment");
            return 
false;
        }
    }
    return 
true;

101 is offline
LinLinLin
Senior Member
Join Date: Sep 2021
Old 11-28-2023 , 06:13   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #7

By use CBaseEntity::FollowEntity, it actually follow the entity i want. But predicted_viewmodel is too strange as an entity.

I am sure it is following the target because it's "m_vecAbsOrgin" is equal to the target.
After that i print the pos info, which make me confused is that "m_vecAbsOrgin" is right pos, but "m_vecOrgin" is zero, whether it is the original or the new viewmodel entity.
And i again use cl_pdump to check viewmodel entity, it is still fixed in pos (0,0,0), even if you teleport it or set it's prop of orgin.

Only one way to make it move is set player's m_hViewmodel prop to this new viewmodel entity, and the origin viewmodel will stay in the current pos and you can see it in firstperson.
LinLinLin is online now
101
Member
Join Date: Nov 2023
Old 11-28-2023 , 07:13   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #8

Quote:
Originally Posted by Bacardi View Post
Here quick tip about these two.

m_vecOrigin (Prop_Send, Prop_Data)
- Think this as "offset".
When entity has no parent (attached to anything), it give "offset" values from world coordinate 0.0, 0.0, 0.0
When entity is attached to another entity, it give "offset" values from parent entity origin (or parent attachment point).
- It is not world "coordinates".
"Offset" zero point is either center of world 0.0, 0.0, 0.0 or from parent entity origin (or parent attachment point).


m_vecAbsOrigin (Prop_Data)
- This give entity "coordinates" from world.



I learned today... harder way... by troubleshooting problem with bumpmines.
#al pacino
101 is offline
Earendil
Senior Member
Join Date: Jan 2020
Location: Spain
Old 12-07-2023 , 19:13   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #9

Quote:
Originally Posted by LinLinLin View Post
code below:
PHP Code:
int entity CreateEntityByName("predicted_viewmodel");
if( 
entity || !IsValidEntity(entity) )
    return ;
SetEntPropEnt(entityProp_Send"m_hOwner"client);
SetEntPropEnt(entityProp_Send"m_hWeapon"weapon);
SetEntityModel(entityRIOTSHIELD_V);
ActivateEntity(entity);
SetVariantString("!activator");
AcceptEntityInput(entity"SetParent"targetentity);
SetVariantString("!activator");
AcceptEntityInput(entity"SetAttached"targetentity);
DispatchSpawn(entity); 
by use cl_pdump to check entity, it still fix in (0.0.0) pos in the world and never follow the targetentity.
is the code got some mistake or just the predicted_viewmodel enttiy can't be attached to other entity?
You need to teleport your entity (use TeleportEntity), when parenting the entity will start moving from its origin relative to the player position and angles.
__________________
>>My plugins<<
>>GitHub<<
Earendil 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 22:16.


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