View Single Post
heroicpower7613
Member
Join Date: Nov 2016
Old 11-01-2017 , 07:25   Re: UNfreezing an entity? func_physbox
Reply With Quote #6

okay i solved it.

before you freeze it, get the entity origin and store it to global float variable like this:
PHP Code:
new Float:g_WorldPosition[3];

public 
Action:CMD_Freeze(clientargs
{
    new 
ent Entity_FindByHammerId(89937"func_physbox");
    
    new 
Float:iEntOrigin[3];
    
GetEntPropVector(entProp_Send"m_vecOrigin"iEntOrigin);
    
    
g_WorldPosition[0] = iEntOrigin[0];
    
g_WorldPosition[1] = iEntOrigin[1];
    
g_WorldPosition[2] = iEntOrigin[2] + 1.0//Move it up just a little bit 
    
    
SetEntityMoveType(entMOVETYPE_NONE);
    
    
PrintToChatAll("entity freezed");
    return 
Plugin_Handled;


when you unfreeze it, use MOVETYPE_VPHYSICS and set the entity origin to what we made before:

PHP Code:
public Action:CMD_UnFreeze(clientargs
{
    new 
ent Entity_FindByHammerId(89937"func_physbox");
    
SetEntityMoveType(entMOVETYPE_VPHYSICS);
    
    
TeleportEntity(entg_WorldPositionNULL_VECTORNULL_VECTOR);
    
    
PrintToChatAll("unfreeze");
    return 
Plugin_Handled;

i think it was stuck inside the ground before because there was moving ground under it that was not flat.
so it works when i teleport the entity slightly up like this g_WorldPosition[2] = iEntOrigin[2] + 1.0;
heroicpower7613 is offline