Raised This Month: $ Target: $400
 0% 

[Resolved] Entity move formula


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 01-07-2008 , 03:37   [Resolved] Entity move formula
Reply With Quote #1

I'm really not good with vector formulas, and I'm trying to figure out how to move an entity around similar to how EntMod moves entities.

I know how to make the entity move in straight lines, but getting it to follow the angle I'm looking while moving my player around is what gets me.

Here is the code I came closest to working but is still way off:
PHP Code:
static Float:playerOrigin[3], Float:playerAngles[3], Float:retVec[3];

pev(idpev_originplayerOrigin);
pev(idpev_anglesplayerAngles);

angle_vector(playerAngles1retVec);

retVec[0] *= playerOrigin[0];
retVec[1] *= playerOrigin[1];
retVec[2] *= playerOrigin[2];

engfunc(EngFunc_SetOriginentityretVec); 

Last edited by hlstriker; 01-07-2008 at 05:20. Reason: resolved
hlstriker is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-07-2008 , 03:55   Re: Entity move formula
Reply With Quote #2

You could have a look at this plugin : http://djeyl.net/forum/index.php?showtopic=50982
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
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
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 11:13.


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