Raised This Month: $51 Target: $400
 12% 

Solved Make entity to follow player aim


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ZaX
Senior Member
Join Date: Jan 2015
Old 04-12-2020 , 16:20   Make entity to follow player aim
Reply With Quote #1

Hi, how can I make the entity to follow the player aim?
Like keeps following his aim, not just placing the entity where he aims

If someone can give me an example that would be nice

Last edited by ZaX; 04-14-2020 at 08:47.
ZaX is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-13-2020 , 05:11   Re: Make entity to follow player aim
Reply With Quote #2

Subtract Look_Origin with entity_Origin normalize the outputs.
Multiple the outputs with the speed desired then set entity velocity to outputs
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
ZaX
Senior Member
Join Date: Jan 2015
Old 04-14-2020 , 01:45   Re: Make entity to follow player aim
Reply With Quote #3

I reached that
PHP Code:
    new LookOrigin[3], EntityOrigin[3], szOutPut[3]
    
pev(idpev_originLookOrigin)
    
pev(pentpev_originEntityOrigin)

    
xs_vec_sub(LookOriginEntityOriginszOutPut
do I normalize like that?
PHP Code:
xs_vec_normalize(szOutPutszOutPut
And then how can I set the entity velocity?

PS> What im trying to do is to make fake entity for player to preview before he places the real one.
Should I use entity think, or only place those codes in fake entity function will be fine?
ZaX is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-14-2020 , 07:23   Re: Make entity to follow player aim
Reply With Quote #4

then you dont need to set velocity just simply set entity's origin where the player is aiming at.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
ZaX
Senior Member
Join Date: Jan 2015
Old 04-14-2020 , 08:01   Re: Make entity to follow player aim
Reply With Quote #5

Yeah but I want it to keep moving as the player moves his aim
ZaX is offline
ZaX
Senior Member
Join Date: Jan 2015
Old 04-14-2020 , 08:45   Re: Make entity to follow player aim
Reply With Quote #6

Thank you
Used ham_entitythink

PHP Code:
new Float:LookOrigin[3];
get_user_hitpoint(idLookOrigin)

entity_set_origin(iEntLookOrigin)
drop_to_floor(iEnt)

// Get User HitPoint Stock

stock get_user_hitpoint(indexFloat:origin[3], maxdist=9999)
{
    new 
gunorigin[3], aimpoint[3];
    
get_user_origin(indexgunorigin1); // 1 - position from eyes (weapon aiming).
    
get_user_origin(indexaimpoint3); // 3 - end position from eyes (hit point for weapon).
    
if( get_distance(gunoriginaimpoint) > maxdist )
    {
        return 
0;
    }

    
IVecFVec(aimpointorigin);

    return 
1;


Last edited by ZaX; 04-14-2020 at 08:47.
ZaX 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 15:42.


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