Raised This Month: $ Target: $400
 0% 

Got a NaN velocity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TBagT
Member
Join Date: Aug 2016
Location: Lithuania
Old 08-24-2016 , 07:20   Got a NaN velocity
Reply With Quote #1

Hello everyone,

So right to the point, I'm trying to make a drone fly near a players head but I get a NaN velocity and not sure why...

PHP Code:

public spawn_droneiddrone_id ) {
        if( 
player_has_droneid ] )
                return;

        new 
DroneDroneInformation ];
        
ArrayGetArrayDronesdrone_idDrone );

        new 
FloatfOrigin];
        
entity_get_vectoridEV_VEC_originfOrigin );

        
fOrigin] += 18.0;
        
fOrigin] += 24.0;

        new 
DroneEntity create_entity"func_breakable" );
        
entity_set_stringDroneEntityEV_SZ_classnameEntName );
        
entity_set_intDroneEntityEV_INT_solidSOLID_TRIGGER );
        
entity_set_intDroneEntityEV_INT_movetypeMOVETYPE_FLY );
        
entity_set_intDroneEntityEV_INT_iuser1drone_id );
        
entity_set_edictDroneEntityEV_ENT_ownerid );
        
entity_set_modelDroneEntityDronedrone_model ] );

        
entity_set_floatDroneEntityEV_FL_takedamage1.0 );
        
entity_set_floatDroneEntityEV_FL_healthDronedrone_health ] );
        
entity_set_floatDroneEntityEV_FL_nextthinkhalflife_time( ) + 0.1 );

        
entity_set_originDroneEntityfOrigin );

        
player_has_droneid ] = true;

        return;
}

public 
drone_think_aidroneEnt ) {
        
// Drono informacija //
        
new DroneDroneInformation ];
        new 
DroneOwner entity_get_edictdroneEntEV_ENT_owner );
        new 
DroneID    entity_get_intdroneEntEV_INT_iuser1 );
        
ArrayGetArrayDronesDroneIDDrone );

        
// Sekiojimas //
        
new FloatfOrigin], FloatfAngles];
        
entity_get_vectorDroneOwnerEV_VEC_originfAngles );
        
entity_get_vectordroneEntEV_VEC_originfOrigin );

        
// Set Angles so it aims forward //
        
fAngles] += 18.0;
        
fAngles] += 24.0;

        
// entity_set_origin( droneEnt, fOrigin );
        
xs_vec_subfAnglesfOriginfOrigin );
        
xs_vec_normalizefOriginfOrigin );
        
xs_vec_mul_scalarfOrigin150.0fOrigin);

        
fOrigin] = 0.0;
        
entity_set_vectordroneEntEV_VEC_velocityfOrigin );

        
// Forwardinam ai //
        
ExecuteForwardDronedrone_forward ], fwResultDroneOwnerdroneEnt );

        
// Pratesiame drono mastyma //
        
entity_set_floatdroneEntEV_FL_nextthinkhalflife_time( ) );

TBagT is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 08-24-2016 , 10:55   Re: Got a NaN velocity
Reply With Quote #2

Check vector fOrigin for (0,0,0) before xs_vec_normalize, there can be divide by zero.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
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 09:46.


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