Raised This Month: $ Target: $400
 0% 

[FIXED]How can I get the origin that in front of the entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wgwgkg
Member
Join Date: May 2011
Old 09-15-2013 , 03:22   [FIXED]How can I get the origin that in front of the entity
Reply With Quote #1

I have tried velocity_by_aim but it doesn't work.
The aim to do that is to create a entity in front of the player
But how can I do this?

Last edited by wgwgkg; 09-15-2013 at 05:56.
wgwgkg is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-15-2013 , 04:27   Re: How can I get the origin that in front of the entity
Reply With Quote #2

velocity_by_aim + player origin should work

Try this :

PHP Code:
GetPlayerFrontOriginiddistanceorigin[3] )
{
    new 
Float:temp[3];
    
pev(idpev_originorigin);
    
pev(idpev_view_ofstemp);
    
origin[2] += temp[2];
    
velocity_by_aim(iddistancetemp);
    
xs_vec_add(origintemporigin);

Usage :
PHP Code:
{
    new 
Float:origin[3];
    
GetPlayerFrontOrigin(id150origin);

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 09-15-2013 at 04:28.
ConnorMcLeod is offline
wgwgkg
Member
Join Date: May 2011
Old 09-15-2013 , 04:45   Re: How can I get the origin that in front of the entity
Reply With Quote #3

It does not work!
Actually, I want the function compatible with other entity such as NPC
wgwgkg is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-15-2013 , 06:20   Re: [FIXED]How can I get the origin that in front of the entity
Reply With Quote #4

I don't know if it'll work because I don't know if ents have view_ofs or v_angle. You'll just have to try. Works with players.

Code:
stock PointByAim(ent, vel, Float:retPoint[3]) {     #if !defined _engine_included && !defined _fakemeta_included     #assert You need to include engine or fakemeta! #endif         new Float:entOrigin[3], Float:entOffsets[3];     #if defined _engine_included     if ( ! is_valid_ent(ent) ) { #else     if ( ! pev_valid(ent) ) { #endif         log_amx("[PointByAim] Entity %d is not valid", ent);         return;     }     #if defined _engine_included     entity_get_vector(ent, EV_VEC_origin, entOrigin);     entity_get_vector(ent, EV_VEC_view_ofs, entOffsets); #else     pev(ent, pev_origin, entOrigin);     pev(ent, pev_view_ofs, entOffsets); #endif         entOrigin[0] += entOffsets[0];     entOrigin[1] += entOffsets[1];     entOrigin[2] += entOffsets[2];     #if defined _engine_included     entity_get_vector(ent, EV_VEC_v_angle, entOffsets); #else     pev(ent, pev_v_angle, entOffsets); #endif         angle_vector(entOffsets, ANGLEVECTOR_FORWARD, entOffsets);         retPoint[0] = entOrigin[0] + entOffsets[0] * vel;     retPoint[1] = entOrigin[1] + entOffsets[1] * vel;     retPoint[2] = entOrigin[2] + entOffsets[2] * vel; }
__________________

Last edited by Black Rose; 09-15-2013 at 06:30.
Black Rose is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 09-15-2013 , 08:43   Re: [FIXED]How can I get the origin that in front of the entity
Reply With Quote #5

PHP Code:
stock angle_to_velocityFloat:angle[3], const Float:distanceFloat:outorigin[3] )
{
    static 
Float:v_forward[3]
    
angle_vector(angleANGLEVECTOR_FORWARDv_forward)
    
outorigin[0] = v_forward[0] * distanceoutorigin[1] = v_forward[1] * distanceoutorigin[2] = v_forward[2] * distance


Last edited by .Dare Devil.; 09-15-2013 at 08:44.
.Dare Devil. is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-15-2013 , 10:44   Re: How can I get the origin that in front of the entity
Reply With Quote #6

Quote:
Originally Posted by wgwgkg View Post
I have tried velocity_by_aim but it doesn't work.
The aim to do that is to create a entity in front of the player
But how can I do this?

Quote:
Originally Posted by wgwgkg View Post
It does not work!
Actually, I want the function compatible with other entity such as NPC

Nice.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply


Thread Tools
Display Modes

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 19:15.


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