by Fuzzy » Sat Apr 14, 2007 1:52 pm
Sorry. Error factor is not something that is specific to GE. The term comes from "margin of error", refering to something being close, but not exact.
Its basically just a variable that you make. I'll try to explain it in generic terms.
Say you want to move an actor very slowly. Perhaps slower than one. Obviously, you cannot move less than 1 pixel, so unless that fractional extra gets stored, you never get anywhere. Luckily in GE, Makslane has done this for us. We dont have to.
Anyway, what happens is that the fractional part gets stored and added each time, and when it exceeds one, The actor moves one(or more) pixels.
In the case of angles, it refers to the fact that from a long distance, you only have to head in the general direction to be moving correctly. As you get closer, you tighten the error factor. Your field of view(or movement) gets smaller as you approach.
I appologise for the simplistic explainations. I write my posts in a way that I hope will be generic and clear(and useful) to a new user and possibly younger user 1, 3 or even 5 years from now. Often pictures and samples help, but they are not guarranteed to remain with the posts.
Now for some code samples and maybe some pictures.
I'll assume you have found the angle to the target, and stored it in a variable called Ang2Targ. We will take that and a float variable called AngErrTerm, which we have set to 10. We are not concerned with distance in this sample.
Imagine Ang2Targ as a line extending into the distance. It has no thickness. AngErrTerm will add that. First, we subtract one half of the error term from the angle.
Ang2Targ = Ang2Targ - (AngErrTerm *0.5);
It is safer to multiply by a decimal than to divide, because you dont risk a division by zero error. Next we add a random number from 0 to the value of AngErrTerm.
Ang2Targ = Ang2Targ + rand(AngErrTerm);
We can simplify both lines into one, but it can make it trickier to read.
Ang2Targ = Ang2Targ - (AngErrTerm *0.5) + rand(AngErrTerm);
And thats it. We have made the solid angle we started with into an angle thats only roughly the same direction. With a larger error term, it becomes less exact.
I'd put this in draw somehow.
Mortal Enemy of IF....THEN(and Inspector Gadget)
Still ThreeFingerPete to tekdino