Unfortunately, no - you can't. I've encountered this several times in my own work. In COD2, the surface which will return a solid entity using bullettrace() is often under a brush/texture and you end up with models hanging in the air. In COD4, this was fixed, and you can get the angles of geometry in a map. But, not in COD2.
Loveboy (3rd March 2014)
model should be good :P
Ah ok :/, thank you Tally
You mean maps\mp\_utility::getplant()? Yeah, been there, seen it, done it. Got the hat to testify! It's not fool-proof. It's the way the COD2 map editor can lay textures on geometry and for the "solid" parts to register below the textures. It does it with walls as well - the decals are slightly forward of the "solid" geo behind them.
This function I converted from COD4 is the best to find solid ground to spawn models on in COD2:
Code:getGroundpoint( entity ) { trace = bullettrace( entity.origin+(0,0,10), entity.origin + (0,0,-2000), false, entity ); groundpoint = trace["position"]; finalz = groundpoint[2]; for( angleCounter = 0; angleCounter < 10; angleCounter++ ) { angle = angleCounter / 10.0 * 360.0; pos = entity.origin + (cos( angle ), sin( angle ), 0); trace = bullettrace( pos+(0,0,10), pos + (0,0,-2000), false, entity ); hitpos = trace["position"]; if( hitpos[2] > finalz && hitpos[2] < groundpoint[2] + 15 ) finalz = hitpos[2]; } return( groundpoint[0], groundpoint[1], finalz ); }
Last edited by Tally; 3rd March 2014 at 17:33.
Use trace["normal"] to find the normal-vector of the surface.
That does work, and im using it in my cod4mod
"Does not work" is an error report for a bug between keyboard and chair.
All hail Artie Effem
Hmmm.. I tried it Tally, but it didn't worked xD
Edit: I know that I make there something wrong xD
Last edited by Loveboy; 3rd March 2014 at 19:41.
To "align" the angles (not position), like IzNoGod said, you need the trace["normal"]:
PHP Code:
orientToNormal( normal )
{
hor_normal = ( normal[ 0 ], normal[ 1 ], 0 );
hor_length = length( hor_normal );
if ( !hor_length )
return( 0, 0, 0 );
hor_dir = vectornormalize( hor_normal );
neg_height = normal[ 2 ] * - 1;
tangent = ( hor_dir[ 0 ] * neg_height, hor_dir[ 1 ] * neg_height, hor_length );
plant_angle = vectortoangles( tangent );
//println("^6hor_normal is ", hor_normal);
//println("^6hor_length is ", hor_length);
//println("^6hor_dir is ", hor_dir);
//println("^6neg_height is ", neg_height);
//println("^6tangent is ", tangent);
//println("^6plant_angle is ", plant_angle);
return plant_angle;
}
// ... somewhere in your code...
minigun.angles = orientToNormal(trace["normal"]);
timescale 0.01