Raised This Month: $ Target: $400
 0% 

calculating different velocities from an origin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 07-14-2011 , 14:57   Re: calculating different velocities from an origin
Reply With Quote #1

Lets give you an idea:
Code:
new Float:explosion_origin[3] // Var which will hold the origin where you want the explosion to take // Retrieve player's origin new Float:player_origin[3] pev( id, pev_origin, player_origin ) // We will get a vector pointing from explosion's origin towards the player // eg: we always get a vector from point.A to point.B if we substract point.A's origin from point.B's origin. new Float:player_vector[3] player_vector[0] = player_origin[0] - explosion_origin[0] player_vector[1] = player_origin[1] - explosion_origin[1] player_vector[2] = player_origin[2] - explosion_origin[2] // We normalize the vector. Basically a normalized vector is vector with a length of 1 unit xs_vec_normalize( player_vector, player_vector ) // Now you can increase the vector's magnitude according to the player's distance from the origin (you can change its magnitude (length) by multipling it by a scalar)

For more info you can read this tutorial coz that is how i learned this vector stuff.
https://forums.alliedmods.net/showthread.php?t=91474
__________________

My Plugins For ZP

Inactive due to College and Studies

Last edited by abdul-rehman; 07-14-2011 at 15:59.
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
liinuus
Senior Member
Join Date: Apr 2010
Old 07-14-2011 , 15:33   Re: calculating different velocities from an origin
Reply With Quote #2

Quote:
Originally Posted by abdul-rehman View Post
Lets give you an idea:
Code:
new explosion_origin[3] // Var which will hold the origin where you want the explosion to take // Retrieve player's origin new player_origin[3] pev( id, pev_origin, player_origin ) // We will get a vector pointing from explosion's origin towards the player // eg: we always get a vector from point.A to point.B if we substract point.A's origin from point.B's origin. new player_vector[3] player_vector[0] = player_origin[0] - explosion_origin[0] player_vector[1] = player_origin[1] - explosion_origin[1] player_vector[2] = player_origin[2] - explosion_origin[2] // We normalize the vector. Basically a normalized vector is vector with a length of 1 unit xs_vec_normalize( player_vector, player_vector ) // Now you can increase the vector's magnitude according to the player's distance from the origin (you can change its magnitude (length) by multipling it by a scalar)

For more info you can read this tutorial coz that is how i learned this vector stuff.
https://forums.alliedmods.net/showthread.php?t=91474
thankls i will try and test an bit, btw dsnt pev_origin need an Float value?
liinuus is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 07-14-2011 , 15:37   Re: calculating different velocities from an origin
Reply With Quote #3

Quote:
Originally Posted by liinuus View Post
thankls i will try and test an bit, btw dsnt pev_origin need an Float value?
Sorry i forgot that, editted it.
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
liinuus
Senior Member
Join Date: Apr 2010
Old 07-14-2011 , 15:46   Re: calculating different velocities from an origin
Reply With Quote #4

Quote:
Originally Posted by abdul-rehman View Post
Sorry i forgot that, editted it.
shudnt the vector be a Float aswell?
liinuus is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 07-14-2011 , 15:59   Re: calculating different velocities from an origin
Reply With Quote #5

Quote:
Originally Posted by liinuus View Post
shudnt the vector be a Float aswell?
Depends, if you substract 2 Float origins then you will get a Float vector (unless u round it off) like i did above
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
liinuus
Senior Member
Join Date: Apr 2010
Old 07-14-2011 , 16:15   Re: calculating different velocities from an origin
Reply With Quote #6

Thank you for the help, i was finally able to figgure it out

Last edited by liinuus; 07-14-2011 at 17:40.
liinuus 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 00:49.


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