Raised This Month: $ Target: $400
 0% 

[Resolved] Entity move formula


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 01-07-2008 , 05:16   Re: Entity move formula
Reply With Quote #3

Thanks a lot, connorr

I was able to get the formula from that plugin. I converted it to use floats instead of integers so it's more accurate.

Here it is if anyone else wants it:
PHP Code:
static Float:origin[3], Float:aimVec[3], Float:entOrigin[3], Float:direction[3], Float:length;
static 
Float:moveTo[3], Float:Mins[3], Float:Maxs[3], distance;

pev(idpev_originorigin);
pev(isMovingEnt[id], pev_originentOrigin);
fm_get_aim_origin(idaimVec);

direction[0] = aimVec[0] - origin[0];
direction[1] = aimVec[1] - origin[1];
direction[2] = aimVec[2] - origin[2];
length get_distance_f(aimVecorigin);

// Avoid division by 0
if(length == 0.0)
    
length 1.0;

distance 200// Set how close you want the ent to be to you
moveTo[0] = origin[0] + direction[0] * distance length;
moveTo[1] = origin[1] + direction[1] * distance length;
moveTo[2] = origin[2] + direction[2] * distance length;

pev(isMovingEnt[id], pev_minsMins);
pev(isMovingEnt[id], pev_maxsMaxs);
moveTo[0] -= (Mins[0] + Maxs[0]) * 0.5;
moveTo[1] -= (Mins[1] + Maxs[1]) * 0.5;
moveTo[2] -= (Mins[2] + Maxs[2]) * 0.5;

engfunc(EngFunc_SetOriginisMovingEnt[id], moveTo); 
hlstriker is offline
 



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 11:13.


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