Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Custom Movement: Help Needed! (https://forums.graalonline.com/forums/showthread.php?t=86886)

scriptless 07-14-2009 02:59 AM

Custom Movement: Help Needed!
 
Okay so what I have here lets me move fine altho it does not let me move flush against the wall.. and if walking between 2 wall tiles.. example: wall, non, non, wall u have to be perfectly in between the walls to move. Also only lets me move at speeds close to (16/16) i think.

Anyone have any suggestions on making movements twards a wall flush? And is there any way to output the collision points of a onwall2?

PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
this.enabled true;
  
setTimer(0.05);
  if ( 
this.enabled == true )
  {
    
disabledefmovement;
  } else {
      
enabledefmovement;
      }
}

function 
onTimeOut()
{
  
this.speed = (8/16);

  for ( 
i=04i++ )
  {
    if ( 
keydown(i) )
    {

  
temp.tw = ( abs(vecx)) == 16 32 ) / 16;
  
temp.th = ( abs(vecy)) == 16 32 ) / 16;
  
temp.aa = ( abs(vecy)) == .5 );
  
temp.tx player.vecx) * temp.aa;
  
temp.ty player.vecy) * temp.aa;
    
      if ( 
player.ani != "walk" && player.ani != "swim") {
        
setAni("walk"null);
      }

      if ( 
this.enabled == true )
      {
        
player.dir i;
        
temp.nx player.vecx(i)*this.speed;
        
temp.ny player.vecy(i)*this.speed;
        if ( !
onwall2temp.txtemp.tytemp.twtemp.th ) ) {
          
player.temp.nx;
          
player.temp.ny;
        }
      }
    } else {
        if ( !
keydown(0) && !keydown(1) && !keydown(2) && !keydown(3) ) {
          if ( !
onwaterplayer.xplayer.) ) {
            
setAni("idle"null);
          }
        }
      }
  }

  if ( 
onwaterplayer.xplayer.) ) {
    if ( 
player.ani != "swim" ) {
      
setAni("swim"null);
    }
  }

  
  
setTimer0.05 );
  
  
// debug only
  
showpoly(200,{temp.tx,temp.ty,temp.tx+temp.tw,temp.ty,temp.tx+temp.tw,temp.ty+temp.th,temp.tx,temp.ty+temp.th});
  
changeimgcolors(200,1,0,0,.25); 
  


Any help or suggestions appreciated.

PS: This is a rough draft. I know its sloppy but its readable non-the-less.

DustyPorViva 07-14-2009 03:13 AM

A common technique to 'close the gap' is usually running a loop like such :
for (temp.i=0;i<playerspeed;i+=1/16)
Then checking for an onwall from the player plus the vecx/y of the player's direction * i. If there is a wall, break the loop and add playerx += vecx(playerdir)*i and so on.

scriptless 07-14-2009 03:29 AM

There are 2 positions my script checks so would I be using 2 onwall checks then instead of my onwall2? I didn't realise onwall2 used more CPU then onwall. So that will be something I need to change.

DustyPorViva 07-14-2009 04:19 AM

Meh, I used onwall2... I find it much more convenient to do two 16x16 onwall2 checks than 4 onwall checks, especially since you only need those two checks for sliding around corners.

12171217 07-14-2009 04:42 AM

Speeds close to 16/16? As in one?

If you mean something along the lines of speeds like x/16, that's fine, as 1/16 is one pixel in Graal coordinates.

DustyPorViva 07-14-2009 04:44 AM

I adjust my onwall2 to compensate for whatever speed the player is moving.

12171217 07-14-2009 07:04 AM

Doesn't that make the player stop further away from the wall..?

DustyPorViva 07-14-2009 05:45 PM

Not if you close the gap like I explained :)

12171217 07-15-2009 01:22 AM

Well I don't see the point of doing onwall2, as you can't have sliding collision then.

DustyPorViva 07-15-2009 01:41 AM

How so? I have sliding collision...


All times are GMT +2. The time now is 12:56 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.