Raised This Month: $ Target: $400
 0% 

[help] vector and angles


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
katna
Senior Member
Join Date: May 2010
Old 03-16-2011 , 15:13   [help] vector and angles
Reply With Quote #1

How do change the velocity to the angle position.

Ex: i change the player angle while he is jumping and he is vector is still the same but i want his velocity to go to the angles position at the same velocity that he was. kinda hard to explain, if you didn't understand i will try to explain again

Last edited by katna; 03-17-2011 at 08:49.
katna is offline
infek
Senior Member
Join Date: May 2009
Location: Behind you
Old 03-16-2011 , 21:25   Re: [help] vector and angles
Reply With Quote #2

Something like this maybe?
PHP Code:
   new Float:flAngle[3]; 
  new 
Float:flSizeMin[3];
  new 
Float:flSizeMax[3];
 
  
entity_get_vectorentEV_VEC_anglesflAngle );
 
  if(
flAngle[1] == 0.0) {
   
flAngle[1] += 1.0// for this too
   
flSizeMin Float:{0.00.00.0// Figure the math out
   
flSizeMax Float:{0.00.00.0}
  }
  else if(
flAngle[1] == 1.0) {
   
flAngle[1] += 1.0;
   
flSizeMin Float:{0.00.00.0}
   
flSizeMax Float:{0.00.00.0}
 }  else { 
// sets it back to normal
   
flAngle Float:{0.00.00.0}
   
flSizeMin Float:{0.00.00.0}
   
flSizeMax Float:{-0.0, -0.00.0}
  }
  
entity_set_vectorentEV_VEC_anglesflAngle );
  
entity_set_sizeentflSizeMinflSizeMax ); 
__________________
"Domo Arigato, Mr. Roboto!"
PM me if you want to know a secret
infek is offline
katna
Senior Member
Join Date: May 2010
Old 03-17-2011 , 08:49   Re: [help] vector and angles
Reply With Quote #3

how size is related? i'm trying to set the same velocity as the player was but in another direction.
katna is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-17-2011 , 09:50   Re: [help] vector and angles
Reply With Quote #4

Try this:

Code:
new Float:angle[3]; velocity_by_aim(id, 10, angle); angle[2] = 0.0; new Float:length = vector_length(angle); angle[2] = velocity[2]; velocity[2] = 0.0; new Float:xyspeed = vector_length(velocity); velocity[0] = angle[0] / length * xyspeed; velocity[1] = angle[1] / length * xyspeed; velocity[2] = angle[2]; entity_set_vector(id, EV_VEC_velocity, velocity);

@infek
That looks like a copy/paste (with a few edits) from blockmaker where it rotates a block model.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
katna
Senior Member
Join Date: May 2010
Old 03-17-2011 , 11:57   Re: [help] vector and angles
Reply With Quote #5

if velocity is the id velocity, the code isn't working well.
your code only works with angles '0 90 0'.

i'm trying to teleport a player and keep is velocity to the angles i changed to him.
i need the player velocity to be the same but at the direction of the tele_angle
this is my code.
PHP Code:
entity_set_vector(idEV_VEC_origintele_origin);
    
static 
Float:velocity[3];
entity_get_vector(idEV_VEC_velocityvelocity);
    
if(
tele_angle[0] != -1.0 && tele_angle[1] != -1.0 && tele_angle[2] != -1.0)
{
    
entity_set_vector(idEV_VEC_anglestele_angle);
    
set_pev(idpev_fixangle1);
}
    
new 
Float:angle[3];
velocity_by_aim(id10angle);
    
angle[2] = 0.0;
    
new 
Float:length vector_length(angle);
    
angle[2] = velocity[2];
velocity[2] = 0.0;
    
new 
Float:xyspeed vector_length(velocity);
    
velocity[0] = angle[0] / length xyspeed;
velocity[1] = angle[1] / length xyspeed;
velocity[2] = angle[2];
    
entity_set_vector(idEV_VEC_velocityvelocity); 

Last edited by katna; 03-17-2011 at 12:00.
katna is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-17-2011 , 12:44   Re: [help] vector and angles
Reply With Quote #6

In that case, do this:

PHP Code:
entity_set_vector(idEV_VEC_origintele_origin);
    
if(
tele_angle[0] != -1.0 && tele_angle[1] != -1.0 && tele_angle[2] != -1.0)
{
    
entity_set_vector(idEV_VEC_anglestele_angle);
    
set_pev(idpev_fixangle1);
    
    new 
Float:velocity[3];
    
entity_get_vector(idEV_VEC_velocityvelocity);
    
    new 
Float:angle[3];
    
engfunc(EngFunc_MakeVectorstele_angle);
    
global_get(glb_v_forwardangle);
        
    
angle[2] = 0.0;
        
    new 
Float:length vector_length(angle);
        
    
angle[2] = velocity[2];
    
velocity[2] = 0.0;
        
    new 
Float:xyspeed vector_length(velocity);
        
    
velocity[0] = angle[0] / length xyspeed;
    
velocity[1] = angle[1] / length xyspeed;
    
velocity[2] = angle[2];
        
    
entity_set_vector(idEV_VEC_velocityvelocity);

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
katna
Senior Member
Join Date: May 2010
Old 03-17-2011 , 17:59   Re: [help] vector and angles
Reply With Quote #7

perfect, thank you very much
katna 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 14:41.


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