AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to drag entity toward us? (https://forums.alliedmods.net/showthread.php?t=184201)

qwerty123 05-02-2012 07:11

How to drag entity toward us?
 
As the tittle said, how can I make the entity to come ( drag ) toward us?

Exolent[jNr] 05-02-2012 09:29

Re: How to drag entity toward us?
 
Code:
stock VelocityFromAtoB(const Float:originA[3], const Float:originB[3], const Float:speed, Float:output[3]) {     output[0] = originB[0] - originA[0];     output[1] = originB[1] - originA[1];     output[2] = originB[2] - originA[2];         new Float:length = vector_length(output);         output[0] *= (speed / length);     output[1] *= (speed / length);     output[2] *= (speed / length); }

Then you can use it like this:
Code:
new Float:playerOrigin[3], Float:entityOrigin[3]; entity_get_vector(id, EV_VEC_origin, playerOrigin); entity_get_vector(ent, EV_VEC_origin, entityOrigin); new Float:speed = 300.0; // units per second new Float:velocity[3]; VelocityFromAtoB(entityOrigin, playerOrigin, speed, velocity); entity_set_vector(ent, EV_VEC_velocity, velocity);

Liverwiz 05-02-2012 10:06

Re: How to drag entity toward us?
 
looking for this?

http://forums.alliedmods.net/showthread.php?p=541795


All times are GMT -4. The time now is 07:47.

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