AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to make entity follow players aim ? (https://forums.alliedmods.net/showthread.php?t=108601)

NiHiLaNTh 11-07-2009 09:15

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

Arkshine 11-07-2009 09:36

Re: How to make entity follow players aim ?
 
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.

NiHiLaNTh 11-07-2009 11:50

Re: How to make entity follow players aim ?
 
Can you explain me more about first and second statements

Arkshine 11-07-2009 12:16

Re: How to make entity follow players aim ?
 
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 );

NiHiLaNTh 11-07-2009 12:56

Re: How to make entity follow players aim ?
 
This works. Thank you very much ! :)


All times are GMT -4. The time now is 17:31.

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