Raised This Month: $ Target: $400
 0% 

How to make entity follow players aim ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 11-07-2009 , 09:15   How to make entity follow players aim ?
Reply With Quote #1

How to make entity follow players aim ?
Like in Half-Life.When you use rocketlauncher it fires rocket and it follows your aimpoint
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-07-2009 , 09:36   Re: How to make entity follow players aim ?
Reply With Quote #2

Basically,

- You retrieve the direction between the aim point and your origin
- Your normalize the vector
- You convert the vector into an angle.
- You set this new angle for the entity.
__________________
Arkshine is offline
Old 11-07-2009, 09:44
Arkshine
This message has been deleted by Arkshine. Reason: lag
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 11-07-2009 , 11:50   Re: How to make entity follow players aim ?
Reply With Quote #4

Can you explain me more about first and second statements
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-07-2009 , 12:16   Re: How to make entity follow players aim ?
Reply With Quote #5

Sorry not exactly what I wanted to say.

For 1/ and 2/ ; I was meant the direction between the end position ( where you aim ) and the entity origin.
By getting the direction you can retrieve an angle of it and changing the entity angle.

Code:
new Float:AimOrigin[3]; new Float:EntityAngles[3]; new Float:EntityOrigin[3]; new Float:Direction[3]; xs_vec_sub( AimOrigin, EntityOrigin, Direction ); xs_vec_normalize( Direction, Direction ); vector_to_angle( Direction, EntityAngles ); set_pev( Entity, pev_angles, EntityAngles );
__________________

Last edited by Arkshine; 11-07-2009 at 12:19.
Arkshine is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 11-07-2009 , 12:56   Re: How to make entity follow players aim ?
Reply With Quote #6

This works. Thank you very much !
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
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 17:31.


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