AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [help] vector and angles (https://forums.alliedmods.net/showthread.php?t=152937)

katna 03-16-2011 15:13

[help] vector and angles
 
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

infek 03-16-2011 21:25

Re: [help] vector and angles
 
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 ); 


katna 03-17-2011 08:49

Re: [help] vector and angles
 
how size is related? i'm trying to set the same velocity as the player was but in another direction.

Exolent[jNr] 03-17-2011 09:50

Re: [help] vector and angles
 
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.

katna 03-17-2011 11:57

Re: [help] vector and angles
 
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); 


Exolent[jNr] 03-17-2011 12:44

Re: [help] vector and angles
 
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);



katna 03-17-2011 17:59

Re: [help] vector and angles
 
perfect, thank you very much


All times are GMT -4. The time now is 14:41.

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