AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   moving entity depending on players angle (https://forums.alliedmods.net/showthread.php?t=196759)

ahujenas 09-25-2012 09:58

moving entity depending on players angle
 
Code:

new Float:origin[3];
                                        new Float:angle[3];
                                        entity_get_vector(id,EV_VEC_origin,origin);
                                        entity_get_vector(id,EV_VEC_angles,angle);
                                //origin[0]-=3.5;
                                //origin[2]-=0.8;
                                        origin[0] += ( -3.5 * floatsin( -angle, degrees) ),
                                        origin[2] += ( -0.8 * floatcos( -angle, degrees) ),
                                        entity_set_origin(KaiokenCharge[id], origin);

according to everything, this should move the current entity where the player rotates at the exact angle everytime,but it just sticks it into players waist ( 0,0,0 coordinates ) should I establish the angle also for this to take effect?

ahujenas 09-29-2012 12:40

Re: moving entity depending on players angle
 
Any help?..

edit: in other words, i want to attach the object to players hands, but im doing it by setting its origin from angle ( doesn't work out very well )

p.s i CAN attach it, but I first have to create it in the offset I want it to be

dias 09-30-2012 01:45

Re: moving entity depending on players angle
 
Should be Velocity ?

ahujenas 10-02-2012 08:47

Re: moving entity depending on players angle
 
What do you mean? I've tried doing this in a different way, but it returns 0 after vec normalize

Code:

static Float:aim[3],Float:vec[3],Float:endvec[3],Float:origin[3];
                                        fm_get_aim_origin( id, aim );

                                        pev(id,pev_origin, origin );
                                        client_print(id,print_chat,"origin %0.f %0.f %0.f",origin[0],origin[1],origin[2]);
                                        xs_vec_sub(aim,origin, vec );
                                        client_print(id,print_chat,"vec %0.f %0.f %0.f",vec[0],vec[1],vec[2]);
                                        xs_vec_normalize(vec,endvec);
                                        client_print(id,print_chat,"normalized %0.f %0.f %0.f",endvec[0],endvec[1],endvec[2]);



All times are GMT -4. The time now is 08:12.

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