AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   entity origin ! (https://forums.alliedmods.net/showthread.php?t=113327)

K.K.Lv 12-25-2009 14:00

entity origin !
 
2 Attachment(s)
We always set the entity origin used
PHP Code:

pev(idpev_originorigin)
//...
set_pev(entitypev_originorigin

How to set the entity origin in front of player ?

sorry for my bad en ?

just look at the photo

minimiller 12-25-2009 14:05

Re: entity origin !
 
Code:
new Float:flOrigin[3]; pev(id, pev_origin, flOrigin); flOrigin[0] += 50; set_pev(ent, pev_origin, flOrigin);

if that dosent work, try changing "flOrigin[0]" to "flOrigin[1]"

K.K.Lv 12-25-2009 14:14

Re: entity origin !
 
both dosen't work !

Arkshine 12-25-2009 14:15

Re: entity origin !
 
- Get the eye position ( pev_origin + pev_view_ofs )
- Get the forward direction ( EngFunc_MakeVectors on the player's view angle ( pev_v_angle ), then using glb_v_forward )
- Then scale the direction by the length yo want and add it the eye position calculated before.

K.K.Lv 12-25-2009 14:29

Re: entity origin !
 
Do you mind give me some example !

K.K.Lv 12-25-2009 14:34

Re: entity origin !
 
PHP Code:

pev(idpev_originorigin)
pev(idpev_view_ofsview)
engfunc(EngFunc_MakeVectorsview)
global_get(glb_v_forward50

like this ?
and I have no idea how to set !
I don't know what func to be called !

Arkshine 12-25-2009 14:39

Re: entity origin !
 
Code:
#include <amxmodx> #include <fakemeta> enum _:Angle_t { Float:Pitch, Float:Yaw, Float:Roll }; enum _:Coord_t { Float:x, Float:y, Float:z }; #define VectorMA(%0,%1,%2,%3) ( %3[ x ] = %0[ x ] + %1 * %2[ x ], %3[ y ] = %0[ y ] + %1 * %2[ y ], %3[ z ] = %0[ z ] + %1 * %2[ z ] ) Test ( const player ) {     const Float:LENGTH = 150.0;         new Float:origin    [ Coord_t ];     new Float:dirForward[ Coord_t ];     new Float:viewAngles[ Angle_t ];         pev( player, pev_origin, origin );     pev( player, pev_v_angle, viewAngles );         engfunc( EngFunc_MakeVectors, viewAngles );     global_get( glb_v_forward, dirForward );         VectorMA( origin, LENGTH, dirForward, origin );     // origin is now at 150 units in front of player. }

K.K.Lv 12-25-2009 15:23

Re: entity origin !
 
Thx ArkShine !
test it and work fine !

nikhilgupta345 03-20-2011 11:03

Re: entity origin !
 
Sorry for bringing back an old topic, but I was wondering when would be the best time to use this if I am trying to keep the entity constantly in front of the player. Would it be best used in PreThink?


All times are GMT -4. The time now is 04:12.

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