Raised This Month: $ Target: $400
 0% 

Velocity from player eyes.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 11-24-2014 , 11:41   Velocity from player eyes.
Reply With Quote #1

Hi, how to throw grenade from player eyes position?
FromTheFuture is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-24-2014 , 13:25   Re: Velocity from player eyes.
Reply With Quote #2

Perhaps velocity_by_aim()?
klippy is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 11-24-2014 , 13:55   Re: Velocity from player eyes.
Reply With Quote #3

Quote:
Originally Posted by KliPPy View Post
Perhaps velocity_by_aim()?
I'm try to use it, but grenade flies from the hand, not from the eyes.
But I will try again.

Last edited by FromTheFuture; 11-24-2014 at 13:57.
FromTheFuture is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-24-2014 , 14:03   Re: Velocity from player eyes.
Reply With Quote #4

I don't think so. If it flew from the hand, it would be the attachment origin, not the aim origin. However, you may try this:
PHP Code:
new FloatfvOrigin[3], FloatfvViewOfs[3];
pev(idpev_originfvOrigin);
pev(idpev_view_ofsfvViewOfs);
xs_vec_add(fvOriginfvViewOfsfvOrigin); 
After that, your fvOrigin[] variable should hold eyes position.
klippy is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 11-24-2014 , 14:10   Re: Velocity from player eyes.
Reply With Quote #5

Quote:
Originally Posted by KliPPy View Post
I don't think so. If it flew from the hand, it would be the attachment origin, not the aim origin. However, you may try this:
PHP Code:
new FloatfvOrigin[3], FloatfvViewOfs[3];
pev(idpev_originfvOrigin);
pev(idpev_view_ofsfvViewOfs);
xs_vec_add(fvOriginfvViewOfsfvOrigin); 
After that, your fvOrigin[] variable should hold eyes position.
Thank U. But how I can add velocity to it?
PHP Code:
public fw_SetModel(entity, const model[])
{
    new 
id pev(entitypev_owner);
    
    if(
equali(model"models/w_hegrenade.mdl"))
    {    
        new 
Floatvel[3];
        
pev(entitypev_velocityvel);
        
        if(!
vel[0]) return;
        
        
        
set_pev(entitypev_modelindexm);
        
set_pev(entitypev_movetypeMOVETYPE_FLYMISSILE)
        
        new 
FloatfvOrigin[3], FloatfvViewOfs[3];
        
pev(idpev_originfvOrigin);
        
pev(idpev_view_ofsfvViewOfs);
        
xs_vec_add(fvOriginfvViewOfsfvOrigin);  

        
set_pev(entitypev_velocity, ???) // ???
            
        
set_pev(entitypev_nextthinkget_gametime() + 99999.9);
    }
    

FromTheFuture is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-24-2014 , 14:46   Re: Velocity from player eyes.
Reply With Quote #6

Well, in that case:
Code:
new Float: fvAngle[3];
pev(id, pev_v_angle, fvAngle); // Get player's view angle
angle_vector(fvAngle, ANGLEVECTOR_FORWARD, fvAngle); // Transfer angle vector to a vector
xs_vec_normalize(fvAngle, fvAngle); // Create unit vector
xs_vec_mul_scalar(fvAngle, 200.0, fvAngle); // Multiply vector by 200.0
After that, fvAngle[] would be velocity you want to set for your grenade. Red number in code above is velocity you want to set.
klippy is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 11-24-2014 , 15:05   Re: Velocity from player eyes.
Reply With Quote #7

KliPPy, anyway =(
http://www.youtube.com/watch?v=1rLZi...ature=youtu.be
FromTheFuture is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-24-2014 , 15:21   Re: Velocity from player eyes.
Reply With Quote #8

So, you mean it is offset a bit to the left? You could've said it at the beginning...
I don't think its the problem in the code, but in your model. It could have wrong origin. Try testing it with another model that you are 100% percent sure it has centered origin.
klippy is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 11-24-2014 , 17:41   Re: Velocity from player eyes.
Reply With Quote #9

Quote:
Originally Posted by KliPPy View Post
So, you mean it is offset a bit to the left? You could've said it at the beginning...
I don't think its the problem in the code, but in your model. It could have wrong origin. Try testing it with another model that you are 100% percent sure it has centered origin.
I said it before, just I did not know about model .qc origin.
FromTheFuture is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 11-24-2014 , 18:20   Re: Velocity from player eyes.
Reply With Quote #10

Thank You again, I found correct models.
FromTheFuture is offline
Reply


Thread Tools
Display Modes

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 17:39.


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