RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
2k3 catepillar with decent slip-through

0 Members and 1 Guest are viewing this topic.

****
Bitch
Rep:
Level 87
Bits'n'Pixels
Okay, I used a NPC follow event and loved it, but with the major hitch that you get trapped and potentially game-over'd in narrow corridors where the NPC gets in your way.  This is the tutorial I used for the NPC-follow.  There's no need for me to write it all out so here it is....

http://rmrk.net/index.php/topic,13909.0.html

What I want is a slip-through so you can walk through the NPC and get out of narrow areas without the NPC sitting on top of or beneath hero and making it look invariably shit. I sat and devised a wee way to get a decent slip-through that lets you pass through the NPC, then the NPC stays behind you. No one else seems to have written this anywhere I can find on the net so I'll do it now.

It's reeally simple as it happens, but it introduces a couple of bugs, but if addressed properly they needn't ever een show up in-game.  These problems only ever rise if I actively try to make them happen in-game, and even at that, I'm weeding them out.  I'll get to that though.

Okay, this is the first sequence for having the NPC follow you moving up.  I'm assuming you've already read and understood the tutorial I listed.  Here is a citation that I'll edit to put in the new slip-through.

<>Cycle
  <>Wait 0.1s.
  <>Variable Op:[0001:HERO-X] Set, Hero X Pos
  <>Variable Op:[0002:HERO-Y] Set, Hero Y Pos
  <>Variable Op:[0003:NPC1-X] Set, NPC1 X Pos
  <>Variable Op:[0004:NPC1-Y] Set, NPC1 Y Pos
  <>Fork Optn:Varbl[0002:HERO-Y]-V[0004]Small than
    <> Set Chara's Movement: NPC1, Up
    <>
   :End Case
.......

In summary, if you move up, the NPC will follow up behind you.  If you do this for the other three diections he'll do the same.
But this doesn't allow slip-through.

We'll add in another conditional.  Make it do a check for if the sprite [hero] is facing down.  If he is, set a move event command for the hero and have him phase ON, move down and Phase OFF again. 
In the else case (Hero is not facing down then have the NPC move up.

<>Cycle
  <>Wait 0.1s.
  <>Variable Op:[0001:HERO-X] Set, Hero X Pos
  <>Variable Op:[0002:HERO-Y] Set, Hero Y Pos
  <>Variable Op:[0003:NPC1-X] Set, NPC1 X Pos
  <>Variable Op:[0004:NPC1-Y] Set, NPC1 Y Pos
  <>Fork Optn:Varbl[0002:HERO-Y]-V[0004]Small than
    <> Fork Optn: If Hero facing down:
     <> Set Chara's Movement: Hero, Phasing ON, move down, Phasing OFF
    <> Else Case:
     <> Set Chara's Movement: NPC1, Up
     <>
    :End Case
   :End Case
.......

Set this conditional on each direction and have it to do the reverse for each.  (Hero Y co-ordinate is greater than NPC Y co-ordinate check is hero is facinf up, if so phasing on, move up, phasing off, else case NPC move down and so on, so forth....)
This means that if you are moving any way, the NPC will follow and stick behind you withot loating on top of / underneath you.  It also means that if you turn around to face the NPC you will take a step right through him and he'll step to where you were before you turned.  Since you can't turn without moving in the same direction anyway, there is no change to normal movement.
Now your following NPC can walk happily through you without looking crap.  It runs smoothly and looks good, as well as keeps the game running lively, with no fear of getting trapped in a narrow corridor with a follower who is determined to kill you.


Now, I should mention the bugs that this entails:
  Walk through walls:
If at any point you are far away from the NPC, and you turn to face in the direction of them, Hero will take an unstoppeable march through everything in his path (Phasing on) until he reaches the equal co-ordinate.  This is tragic for mazes and the like, where you can simply walk through the walls.
 How to solve this:
Make sure that there is no map where you would be more than a square away from the following NPC (see next problem).  Make sure your switches are in the right places to turn on and off the followers at doors and the like, so the NPC is always behind you.  If this is done, then this bug will never be a problem.

  Lagging behind:
If the NPC lags behind, then if you turn a corner or something or circled an object, the NPC may ery well get stuck behind something and you turning away could lead to the first problem.
  How to solve this:
Again, make sure you are never more than a square away.  If the NPC is set to the right movement frequencey (listed on the linked tutoral)  then you won't be able to outrun your follower unless you are already ahead of him.  Make sure he is always next to you to start off with and he'll stay there.




If all is done correctly, your follower will smoothly follow you as in any other caterpillar event, but you can now walk through the NPC at backturns and he'll even stay behind you the way it started off.  Try it out, but be careful from changing things; I tried many ways and this is the final solution I came up with.  All other ways I could think of lead to serious bugs and unavoidable hitches.  Also, it must be the hero that phases.  If it's the NPC, he doesn't phase off for some reason (or just doesn't phase off in time) and gets stuck phased on on the same square as hero, either below or above and that's just plain bad.

Try it out; hope this helps y'all!

***
Rep:
Level 88
Paradoxial failboats are cool.
Nice tut. It's useful for everyone who wants to do the caterpiller thing, and it includes the ever so helpful slip-through.

I'm going to use this on my next game.
The message below is false.
The message above is true.