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

Manually Set Velocity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-20-2012 , 03:18   Manually Set Velocity
Reply With Quote #1

I'm trying to set the velocity of an entity that is launched from another ( non-player ) entity, according to the launching entity's angles.

I tried playing around with this snippet found in the wiki, but couldn't get it to work:

HTML Code:
new Float:vAngles[3] // plug in the view angles of the entity 
new Float:vReturn[3] // to get out an origin fDistance away 
new Float:fDistance = 400.0 // fDistance being the distance from the entity of your choice 
entity_get_vector(id,EV_VEC_v_angles,vAngles) 
vReturn[0] = floatcos( vAngles[1], degrees ) * fDistance 
vReturn[1] = floatsin( vAngles[1], degrees ) * fDistance 
vReturn[2] = floatsin( -vAngles[0], degrees ) * fDistance
And Ideas?
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 05-26-2012 at 22:38.
hornet is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-20-2012 , 04:08   Re: Manually Set Velocity
Reply With Quote #2

If launcher is a player, use velocity_by_aim(playerindex, flSpeed, vecVelocity)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-20-2012 , 04:09   Re: Manually Set Velocity
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
If launcher is a player, use velocity_by_aim(playerindex, flSpeed, vecVelocity)
Sorry if I was unclear - the launching entity is not a player.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-20-2012 , 04:12   Re: Manually Set Velocity
Reply With Quote #4

Use angles then, not v_angle.

Try :

PHP Code:
Velocity_By_Aimindex Float:flSpeedFloat:flVelocity[3] )
{
    new 
Float:angles[3], Float:dummy[3]
    
pev(indexpev_anglesangles)
    
engfunc(EngFunc_AngleVectorsanglesflVelocitydummydummy)
    
xs_vec_mul_scalar(flVelocityflSpeedflVelocity)

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 05-20-2012 at 04:23.
ConnorMcLeod is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-20-2012 , 05:16   Re: Manually Set Velocity
Reply With Quote #5

Thankyou, works perfect.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet 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 07:49.


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