Raised This Month: $ Target: $400
 0% 

Set origin behind of the enemy?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 11-14-2010 , 13:38   Re: Set origin behind of the enemy?
Reply With Quote #1

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 */
__________________
Hunter-Digital 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:28.


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