Been trying to work out this problem the whole day by myself and finally decided to post here.
I can find the normal of any plane but what I want to do with the plane is place my ent on the plane as well have its angle oriented properly.
I have absolutely no idea why this doesn't work.
Any help will be appreciated! Thanks
PHP Code:
public Forward_CmdStart(id, uc_handle, seed)
{
if(!is_user_alive(id))
return;
static iButton; iButton = get_uc( uc_handle, UC_Buttons );
static oldButton ; oldButton = pev(id, pev_oldbuttons);
static Float:vecOrigin[ 3 ], Float:vecViewOfs[ 3 ];
pev( id, pev_origin, vecOrigin );
pev( id, pev_view_ofs, vecViewOfs );
xs_vec_add( vecOrigin, vecViewOfs, vecOrigin );
static Float:vecAngle[ 3 ];
pev( id, pev_v_angle, vecAngle );
engfunc( EngFunc_MakeVectors, vecAngle );
global_get( glb_v_forward, vecAngle );
xs_vec_mul_scalar( vecAngle, 9999.0, vecAngle );
static Float:vecAimOrigin[ 3 ];
xs_vec_add( vecOrigin, vecAngle, vecAimOrigin );
engfunc( EngFunc_TraceLine, vecOrigin, vecAimOrigin, DONT_IGNORE_MONSTERS, id, 0 );
get_tr2( 0, TR_vecEndPos, vecAimOrigin );
static Float:vecNormal[ 3 ];
get_tr2( 0, TR_vecPlaneNormal, vecNormal );
// xs_vec_mul_scalar(vecNormal, 50.0, vecNormal);
static Float: endTraceNormal[3];
xs_vec_add(vecAimOrigin, vecNormal, endTraceNormal)
if( !(iButton & IN_USE) && (oldButton & IN_USE))
{
static iEnt; iEnt = create_entity("info_target");
entity_set_string(iEnt, EV_SZ_classname, g_classname);
entity_set_model(iEnt, g_Model);
new Float: MinBox[3] = { -25.0, -25.0, 0.0 };
new Float: MaxBox[3] = { 25.0, 25.0, 55.0 };
entity_set_size(iEnt, MinBox, MaxBox);
entity_set_origin(iEnt, endTraceNormal);
vector_to_angle(vecNormal, vecNormal)
entity_set_vector(iEnt, EV_VEC_angles, vecNormal);
entity_set_int(iEnt, EV_INT_movetype, MOVETYPE_FLY);
entity_set_int(iEnt, EV_INT_solid, SOLID_BBOX);
entity_set_edict(iEnt, SPORE_BUILDER, id);
entity_set_int(iEnt, EV_INT_team, get_user_team(id));
// drop_to_floor(iEnt);
entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 0.1);
g_EntSpawn[iEnt] = true;
}
}
__________________