Raised This Month: $ Target: $400
 0% 

Entity moving in front of player


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 08-22-2021 , 23:51   Entity moving in front of player
Reply With Quote #1

I am trying to make a entity that move in front of player with Z-cord always on the ground.
This is I got so far. But there are few problem:
- I could use drop_to_floor but idk if calling it every 0.1s is too much for the server to handle.
- If player aim to the group, the entity might just fall into the void
- If put specific Z first (like +100.0 up) then drop to the ground, it might stuck into a wall or object.

PHP Code:
public Item_think(ent)
{
    static 
owner;owner pev(entpev_owner)
    static 
Float:StartPos[3];
    
get_position(id100.00.00.0StartPos); //100.0 just for testing, might be smaller

    
set_pev(entpev_nextthinkget_gametime()+0.1)
}

stock get_position(id,Float:forwFloat:rightFloat:upFloat:vStart[])
{
    static 
Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
    
    
pev(idpev_originvOrigin)
    
pev(idpev_view_ofsvUp//for player
    
xs_vec_add(vOriginvUpvOrigin)
    
pev(idpev_v_anglevAngle// if normal entity ,use pev_angles
    
    
angle_vector(vAngle,ANGLEVECTOR_FORWARDvForward//or use EngFunc_AngleVectors
    
angle_vector(vAngle,ANGLEVECTOR_RIGHTvRight)
    
angle_vector(vAngle,ANGLEVECTOR_UPvUp)
    
    
vStart[0] = vOrigin[0] + vForward[0] * forw vRight[0] * right vUp[0] * up
    vStart
[1] = vOrigin[1] + vForward[1] * forw vRight[1] * right vUp[1] * up
    vStart
[2] = vOrigin[2] + vForward[2] * forw vRight[2] * right vUp[2] * up

__________________
My plugin:

Last edited by Celena Luna; 08-23-2021 at 00:47.
Celena Luna is offline
 


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 07:44.


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