AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Set origin behind of the enemy? (https://forums.alliedmods.net/showthread.php?t=143102)

xLeoNNN 11-14-2010 13:22

Set origin behind of the enemy?
 
Hello!, someone knows since I can do, that on having written / something, the player's transport, but behind the enemy?
that put the origin behind the enemy. Please!

Hunter-Digital 11-14-2010 13:38

Re: Set origin behind of the enemy?
 
It's simple, you get the player's origin, his forward direction and add the origin to the negatively multiplied forward direction by how many units you want it behind the player's origin.

Quick code, 100 units behind the player's VIEW (if player looks down, the origin will be up, if he looks streight ahead, the origin will be behind him)
Code:

new Float:fOrigin[3]
new Float:fAngles[3]
new Float:fForward[3]

entity_get_vector(id, EV_VEC_origin, fOrigin)
entity_get_vector(id, EV_VEC_v_angle, fAngles)

angle_vector(fAngles, ANGLEVECTOR_FORWARD, fForward)

fOrigin[0] += -fForward[0] * 100
fOrigin[1] += -fForward[1] * 100
fOrigin[2] += -fForward[2] * 100 /* remove this if you don't want it to affect the origin if player looks up or down */

/* fOrigin contains player's behind view origin */


xLeoNNN 11-14-2010 15:00

Re: Set origin behind of the enemy?
 
Try with it, the increase, this diminishes the fOrigin and fForward, but it did not put me origin :/

fysiks 11-14-2010 15:18

Re: Set origin behind of the enemy?
 
Quote:

Originally Posted by xLeoNNN (Post 1349468)
Try with it, the increase, this diminishes the fOrigin and fForward, but it did not put me origin :/

You have to complete the code yourself. He just posted code to find the origin.


All times are GMT -4. The time now is 11:28.

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