check the edge of the platform , it is possible ? help

monomartin

Active member
checks the distance to the edge of the platform and change the animation, is that possible?
http://s2.subirimagenes.com/imagen/previo/thump_9626414ejemo.gif

thump_9626414ejemo.gif
[/URL][/img]
 
I know it's been discussed before, I'm just not sure where sorry.  Try doing a forum search with these keywords platform, edge and walkoff

If I had to guess off my head, I think bWWd's platform mods had this implemented.
 
Hmm... I haven't made any scripts for that purpose yet BUT I have made one to change direction on edge of platform. That script is used to keep enemy on top of platform (the enemy is walking back n forth)

It should be easy to modify that script to change animation instead though I need to see if defining platform's length and height is required or not
 
Something I was thinking about for my ring-in/ring-out system.
One more thing I put in "infinite standby" because it seems really hard to script.
Good luck, I hope your problem will be fixed.
 
I thought to change this , but not how to detect the edge

void stairwalk(int Dist)
{// Checks if there is short wall in front of player
// If there is short wall, player will move up to walk up stairs
  void self = getlocalvar("self");
  int Direction = getentityproperty(self, "direction");
  int x = getentityproperty(self, "x");
  int y = getentityproperty(self, "a");
  int z = getentityproperty(self, "z");
  int b = getentityproperty(self, "base");
  float H;
  int Move = 5;

  if(Direction == 0){ //Is entity facing left?                 
    Dist = -Dist; //Reverse Dist to match facing             
    Move = -Move; //Reverse Move to match facing
  }

  H = checkwall(x+Dist,z);

  if(H > b && H <= 9+b){
    changeentityproperty(self, "position", x+Move, NULL(), y+10);
  }
}
 
stairwalk is used to ascend stairs made by set of steps defined by wall. It's different than platform edge detection, in fact it's the opposite

Anyways, I've made a decent platform edge detection script. Here's the script:
Code:
anim	idle
@script
    void self = getlocalvar("self");
    int Dir = getentityproperty(self, "direction");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "a");
    int z = getentityproperty(self, "z");
    void Plat = checkplatformbelow(x, z, y+1);
    void PlatA; void PlatB;
    int C = 16; // detection range

    if(Plat){ // on a platform
      if(Dir==1){
        PlatA = checkplatformbelow(x+C, z, y+2);
        PlatB = checkplatformbelow(x+C, z, y-2);
      } else {
        PlatA = checkplatformbelow(x-C, z, y+2);
        PlatB = checkplatformbelow(x-C, z, y-2);
      } 

      if(PlatA==PlatB){
	changeentityproperty(self, "animation", openborconstant("ANI_IDLE2"));
      }
    }
@end_script
...

The script does change player's animation when standing near edge of platform
However, the bug with this script is for some reason after changing animation, IDLE2 is not played properly. Can't figure out why  :-\
I choose to change to another IDLE animation cause usually player can move and act normally in that animation
 
hello and I spent the entire morning writing and not for what reason I can not detect the edge of the platform I stand on the edge and does not change the animation .... any ideas? or suggestions? I hope it is understood not speak English ... thank you!
 
I found that the wall did not detect me , but now I have the problem that when I stand on the wall constantly changing animation , rather than only when I reach the edge

@script
    void self = getlocalvar("self");
    int Dir = getentityproperty(self, "direction");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "a");
    int z = getentityproperty(self, "z");
    void Plat = checkwall(x, z, y+1);
    void PlatA; void PlatB;
    int C = 16; // detection range

    if(Plat){ // on a platform
      if(Dir==1){
        PlatA = checkwall(x+C, z, y+2);
        PlatB = checkwall(x+C, z, y-2);
      } else {
        PlatA = checkwall(x-C, z, y+2);
        PlatB = checkwall(x-C, z, y-2);
      }

      if(PlatA==PlatB){
changeentityproperty(self, "animation", openborconstant("ANI_follow1"));
      }
    }
@end_script
 
Emm... monomartin, let us confirm this: do you want to find edge of platform OR edge of wall?
I asked cause the script for each will be different i.e replacing checkplatform with checkwall is not enough
 
Ah I see, okay here's the script:
Code:
anim	idle
@script
    void self = getlocalvar("self");
    int Dir = getentityproperty(self, "direction");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "a");
    int z = getentityproperty(self, "z");
    int Wall = checkwall(x, z);
    int C = 20;
    int WallC;

    if(Wall>0){ // on a platform
      if(Dir==1){
        WallC = checkwall(x+C, z);
      } else {
        WallC = checkwall(x-C, z);
      } 

      if(WallC < y){
	changeentityproperty(self, "animation", openborconstant("ANI_IDLE2"));
      }
    }
@end_script
...

Just like previous script, when edge of wall is detected 20 pixels in front of player, player will change to IDLE2 animation
 
Bloodbane said:
However, the bug with this script is for some reason after changing animation, IDLE2 is not played properly. Can't figure out why  :-\
I choose to change to another IDLE animation cause usually player can move and act normally in that animation

I can't think off my head, but when you want to switch to idle anim, don't we need to also set some IDLE status/flag instead of just changing animation?

something like,

Code:
setidle(self);

OR

Code:
changeentityproperty(self, "aiflag", "idling", 1);
 
I did try this:

Code:
setidle(self, openborconstant("ANI_IDLE2"));

It did change the animation but as I posted above, IDLE2 animation is stuck in first frame
Maybe I could try altering  aiflag as you suggested but I've fixed this problem by setting idle command in IDLE2
 
Perhaps I should create a new thread about it, but...
Is there a chance this script can be used in inverted situation (walk up on a platform)

For my game system I would like the characters and enemies to have the ability to get on divere platforms (wrestling ring, barrel, crates...) by playing a custom "climb" animation.

The conditions would be :
-platform height under 100
-player is in walk anim
-player is facing the platform
-and of course being very close of the platform

This code would be a useful one for some platforming games as well
 
nedflandeurse said:

That's quite easy to do, far moreso than detecting the edge below you. The onblock scripts are how you would do this. Just find out what animation you are in and what is blocking you (both available in the script), and switch your animation to the climb (accent, whatever). It works perfectly because the AI will always "push" against anything blocking it, triggering the onblock event and in turn causing the climb animation to start.

It also works perfectly on players if you want to go that route. For example, you could trigger an automatic climb or jump when you walk to the base of a higher platform on the Z axis.

DC
 
Back
Top Bottom