Banner
Views: 882,638,924
Time:
8 users online: chickaDEE Magazine, Evernn, FrozenQuills, Moonlightgamer5, Natsuz2, OhMuramatsu, quietmason, slopcore - Guests: 42 - Bots: 75 Users: 49,443 (2,432 active)
Latest: Meeko7
Tip: Avoid blind jumps. If the player has to jump down a random hole to proceed with no indication at all that they can go down there, you've done something wrong!Not logged in.
Collision/Interaction Explanation
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - Collision/Interaction Explanation
Pages: « 1 » Link
Hi.

I'm trying to get a handle on how collision and interaction works in SMW. I've looked around the forums, played with tools, etc. But I was wondering if there's some explanation somewhere to help get a high-level understanding.

So far, I know that Player-block interaction and player-sprite interaction work differently, and there's some subtleties with Layer 1/2 vs layer 3. I keep seeing references to "clipping". I've tried to look at the disassembly. But I was hoping for some pointers to a guide or document or explanation for how it works from a high level.

Some stuff that I have looked at:
- Mario Interaction Points document - https://www.smwcentral.net/?p=section&a=details&id=13101
- Interaction Editor - https://www.smwcentral.net/?p=section&a=details&id=15234
- Questions about interactions post - https://www.smwcentral.net/?p=viewthread&t=94617&page=1&pid=1475961#p1475961
- smw-tas tools with hitbox visualization - https://github.com/brunovalads/smw-stuff/blob/master/SMW-BizHawk.lua

I have some sense, but I feel like I'm not quite grasping how it works.

In a perfect world, I'd find something like this one for Sonic: http://info.sonicretro.org/Sonic_Physics_Guide. But any pointers would be great.


Clipping is basically just another name for hitbox, it refers to the values the game uses to determine whether two hitboxes are in contact or "clipping" into each other. There's two kinds of clipping values in SMW, based on the kind of interaction being processed.

For sprite-sprite interaction, it uses square hitboxes defined by an X/Y offset, width, and height. All it has to check then is, are the two hitboxes separated by a distance wider than their height/width? If so, then they're not in contact. See $03B72B for the source code of that (along with the related routines at $03B664, $03B69F, and $03B6E5 which handle fetching the clipping data).

For sprite-object interaction, it uses interaction points. These are single-pixel points defined around the sprite that each seperately process interaction with the tile they're touching. Because processing all of these points would be taxing on the SNES's processor, it usually optimizes it a bit by skipping certain points when unnecessary.
- For non-Mario sprites, the game assigns four interaction points at the middle of each edge of a square hitbox. It only processes two of these points per frame, one of the top/bottom points and one of the left/right points. If the sprite is moving along a particular axis, it processes the point in the direction of that movement. If the sprite is stationary along an axis, it alternates between left/top and right/bottom points each frame (this is what causes e.g. the "jittering" when you shove a carryable sprite inside a solid block).
- For Mario, the game assigns six interaction points: one on top of Mario, one in the center of him, two on the side of him (one next to his head, and one next to his body), and two for each of his feet. For the two side points, it differentiates between left/right sides by which side of the block Mario is on (Smallhacker's document has a mistake in that it refers to this as "standing" vs "walking"; Mario's movement does not matter). Depending on what certain interaction points are touching, it may also skip processing certain other points (e.g. it skips the side points if the center point is inside a solid block, or the side-head point if the side-body point is inside a solid tile).

Now, the reason why Layer 3 interaction works a bit differently from Layer 1/2 interaction is that it doesn't process the interaction points for it. Instead, Layer 3 has its interaction hardcoded; for the tides it just checks if Mario's Y position is below a certain line or not. For more-advanced interaction, you'd want to do something similar to what is already done for the Layer 1/2 interaction. If you want to see the original game's routine for that, see $00EB77 (although I should warn you that that routine is a *mess* due to Nintendo just kinda cramming all of the tile interaction logic into it).

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
In addition to those above, Fireballs and the cape can interact with blocks as well. Those use only one interaction point.
There also is a separate block interaction routine used by line-guided sprites. It works with four interaction points, each four pixels alway from the sprite position.

Originally posted by Thomas
Now, the reason why Layer 3 interaction works a bit differently from Layer 1/2 interaction is that it doesn't process the interaction points for it. Instead, Layer 3 has its interaction hardcoded; for the tides it just checks if Mario's Y position is below a certain line or not.

Actually, the tide is secretely a foreground layer 2 level which is why you can change the tide's acts like setting with Lunar Magic since a couple versions ago and why you can use only half of the available screens.

There also is the layer 3 smasher which uses a classical hitbox which is why it doesn't act like a block and more like a sprite.

--------------------
Okay, my layout looks ugly.
Pages: « 1 » Link
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - Collision/Interaction Explanation

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2021 - SMW Central
Legal Information - Privacy Policy - Link To Us


Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • Super Mario Bros. X Community
  • ROMhacking.net
  • Mario Fan Games Galaxy
  • sm64romhacks