AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved have entity move where i aim at. (https://forums.alliedmods.net/showthread.php?t=309276)

BANDIT228 07-19-2018 14:53

have entity move where i aim at.
 
public AIM(id)
{
if (is_valid_ent(id))
{
new Float:Velocity[3]
VelocityByAim(pev(id,pev_owner), 1000, Velocity)
entity_set_vector(id, EV_VEC_velocity, Velocity)
new Float:NewAngle[3]
entity_get_vector(id, EV_VEC_v_angle, NewAngle)
entity_set_vector(id, EV_VEC_angles, NewAngle)
}
}

currently i use that...........dont find any other good examples....

i am sure i need to use "get user origin"

thing is....i spawn a entity form another player...........that entity should fly to the position i aim at.

right now i only takes my angles.....

but i want it that i look at the ground and it flys there.

anyone has a snippet for me?

BANDIT228 07-20-2018 00:13

Re: have entity move where i aim at.
 
no one?



stock fm_get_aim_origin(index, Float:origin[3]) {
new Float:start[3], Float:view_ofs[3];
pev(index, pev_origin, start);
pev(index, pev_view_ofs, view_ofs);
xs_vec_add(start, view_ofs, start);

new Float:dest[3];
pev(index, pev_v_angle, dest);
engfunc(EngFunc_MakeVectors, dest);
global_get(glb_v_forward, dest);
xs_vec_mul_scalar(dest, 9999.0, dest);
xs_vec_add(start, dest, dest);

engfunc(EngFunc_TraceLine, start, dest, 0, index, 0);
get_tr2(0, TR_vecEndPos, origin);

return 1;
}



---------------------------------------------------





?
new Float:AimOrigin[3];
new Float:EntityAngles[3];
new Float:EntityOrigin[3];
new Float:Direction[3];

xs_vec_sub( AimOrigin, EntityOrigin, Direction );
xs_vec_normalize( Direction, Direction );

vector_to_angle( Direction, EntityAngles );
set_pev( Entity, pev_angles, EntityAngles );
?


which one would be better?


All times are GMT -4. The time now is 16:51.

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