Posted By: 82RJZAE
Snap to Ground - 07/28/12 20:23
Hi, can anyone provide a snippet about how to snap a model to the ground using c_trace? I can't seem to get it to work.
VECTOR vec_min; VECTOR vec_max; wait(1); c_setminmax(me); vec_for_min(vec_min, me); vec_for_max(vec_max, me); result = c_trace(vec_max, vector(vec_max.x,vec_max.y,vec_max.z-1000), IGNORE_ME | IGNORE_MODELS | IGNORE_PASSABLE | USE_BOX | IGNORE_SPRITES); // trace from the origin to the floor and store the result my.z -= target.z; my.z += (vec_max.z-vec_min.z);
vec_set(my.x, target.x);//place object at scanned point my.z += my.min_z;//possible you can add some more quants if you vant it to not stuck in ground(if using c_move aftervards)
result = c_trace(my.x,vector(my.x,my.y,my.z-2*some_distance),IGNORE_ME | etc.);