How to code?

Posted By: molotov

How to code? - 04/01/07 18:18

I've have a player that approches a wall, then I press a button and the player creates a trace to detect the wall. When he detects a wall, the player should be placed a 10 quants away from that wall and facing the wall, no matter what the player original position and angle was. Does someone know to code this effect. Hope this makes sense to someone, thanks anyway. Molotov
Posted By: xXxGuitar511

Re: How to code? - 04/01/07 20:21

var tDist = 100;

Function doIt()
{
vec_set(temp, vector(tDist, 0, 0));
vec_rotate(temp, my.pan);
if (c_trace(my.x, temp, ignore_me))
{
// Found a wall!
vec_to_angle(my.pan, normal);
ang_rotate(my.pan, vector(180, 0, 0));
//
vec_set(my.x, target);
vec_set(temp, vector(-10, 0 0));
vec_rotate(temp, my.pan);
vec_add(my.x, temp);
}
}



tDist is the range it should trace for a wall. Then just call tDist from your entity's action. If it finds a wall, then it will face it from 10 quants away.
Posted By: molotov

Re: How to code? - 04/02/07 12:47

Thanks xXxGuitar511, it's working great, just like I wanted.
Posted By: xXxGuitar511

Re: How to code? - 04/02/07 13:32

That'll be $5 please...


Just kiddin' - your welcome... lol.
© 2023 lite-C Forums