Raised This Month: $ Target: $400
 0% 

Keeping entity at a distance


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 08-23-2021 , 13:58   Keeping entity at a distance
Reply With Quote #1

Hello,
I am trying to keep a solid entity at a certain distance from player's view.
For example: At 150 units in front of player and tracking the distance from player to entity.

So far I am setting the entity velocity to keep it at a distance from player's view, but it works only if I move backwards, not forwards too.

entity_set_aim() function is called on every think of entity.

Code:
Code:
stock entity_set_aim(ent, player) {     static Float:origin[3], Float:ent_origin[3], Float:angles[3]     pev(player, pev_origin, origin)     pev(ent, pev_origin, ent_origin)           xs_vec_sub(origin, ent_origin, origin)     xs_vec_normalize(origin, origin)     vector_to_angle(origin, angles)           angles[0] = 0.0     if(entity_range(ent, player) > ENT_DISTANCE)     {         set_velocity(ent, angles)         angles[1] -= 90.0         set_pev(ent, pev_angles, angles)     } } stock set_velocity(ent, Float:angles[3]) {     static Float: Direction[3]     angle_vector(angles, ANGLEVECTOR_FORWARD, Direction)     xs_vec_mul_scalar(Direction, float(Speed), Direction) // float(-Speed)     set_pev(ent, pev_velocity, Direction) }

Edit: Just achieved to move entity forwards and backwards by making the Speed positive and negative. But the entity is not staying in front of player.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 08-23-2021 at 14:41.
Shadows Adi 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:43.


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