View Single Post
Earendil
Senior Member
Join Date: Jan 2020
Location: Spain
Old 12-07-2023 , 18:13   Re: [L4D2] predicted_viewmodel can't set attach to other entity
Reply With Quote #7

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