Translations of this page:

Script to prevent actor from walking thanks to 3d/2d conversion imperfection

Sometimes you can encounter the following problem. Your actor stands at some spot he/her walks thanks to the hotspot clicking. You click again on the hostspot and actor strangely enough turns around. This is caused thanks to 3d/2d space conversion and the problem is that the actor thinks, that he has to walk one pixel to the side.

Fix is simple: create a script which you attach to your actor. Inside put the following code:

#include "scripts/base.inc" 
 
var C_DX = 2; // thresholds which define that the actor is on one place  
var C_DY = 2; 
 
function abs(X)  //returns absolute value of the number 
{ 
    if (X <0) X = X*-1; 
    return(X);     
} 
 
method GoTo(DestX,DestY) 
{ 
 
    if (abs(this.X - DestX) < C_DX && abs(this.Y - DestY) < C_DY) return; // Let's not spin by approx clicks.     
        this.GoTo(DestX,DestY); 
}


 
resource/script_to_prevent_actor_from_walking_thanks_to_3d_2d_conversion_imperfection.txt · Last modified: 2008/11/24 19:59 by Jyujinkai
Recent changes RSS feed Creative Commons License Driven by DokuWiki