It is currently Sun Sep 23, 2018 8:45 am

 All times are UTC - 7 hours

 Page 1 of 1 [ 14 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Collision with multijointed spritesPosted: Tue Jun 28, 2016 8:15 am

Joined: Wed May 19, 2010 6:12 pm
Posts: 2751
The way I calculate collision with multijointed sprites is by recalculating the x and y velocity of a joint, and then jump to the same routine as the player and enemies use. If collision occurs, then it bumps up the main object by the same amount.

I want to know if there's a more intuitive way of doing this, that doesn't involve recalculating velocities.

Top

 Post subject: Re: Collision with multijointed spritesPosted: Tue Jun 28, 2016 9:31 am
 Formerly Espozo

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3362
Location: Richmond, Virginia
Why would you ever look at velocities when doing collision checks? Are you putting the entire object in one large hit box, or is there one for every joint?

Top

 Post subject: Re: Collision with multijointed spritesPosted: Tue Jun 28, 2016 10:23 am

Joined: Wed May 19, 2010 6:12 pm
Posts: 2751
So when a character jumps on a platform they don't pop up from underneath.

Top

 Post subject: Re: Collision with multijointed spritesPosted: Tue Jun 28, 2016 12:06 pm

Joined: Sun May 27, 2012 8:43 pm
Posts: 1334
psycopathicteen wrote:
So when a character jumps on a platform they don't pop up from underneath.

I'm confused. What would make this happen? Perhaps I'm misunderstanding what you mean by popping up from underneath.

Top

 Post subject: Re: Collision with multijointed spritesPosted: Tue Jun 28, 2016 12:21 pm

Joined: Wed May 19, 2010 6:12 pm
Posts: 2751
If there is a platform you can jump through, you'd end up snapping to the platform if you get close to it.

Top

 Post subject: Re: Collision with multijointed spritesPosted: Tue Jun 28, 2016 12:27 pm

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10814
Location: Rio de Janeiro - Brazil
Can't you simply not do the snapping is this case? Snap only when the object is already "grounded", so that it runs along the ground, or when it's in the air but moving down, so it can only land on the ground from above.

Top

 Post subject: Re: Collision with multijointed spritesPosted: Tue Jun 28, 2016 12:40 pm

Joined: Sun May 27, 2012 8:43 pm
Posts: 1334
psycopathicteen wrote:
If there is a platform you can jump through, you'd end up snapping to the platform if you get close to it.

I see. Yes, in this case checking that dY > 0 is important.

Top

 Post subject: Re: Collision with multijointed spritesPosted: Tue Jun 28, 2016 12:56 pm

Joined: Wed May 19, 2010 6:12 pm
Posts: 2751
...and if the character was above the platform before he landed.

I guess this isn't important for multijointed sprites.

Top

 Post subject: Re: Collision with multijointed spritesPosted: Tue Jun 28, 2016 12:57 pm

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10814
Location: Rio de Janeiro - Brazil
Wait, is this for collisions between multijointed sprites and the level map? That could be very complicated, depending on what the extra pieces are... if they're legs, the object should be able to step on higher ground with one foot without moving all the other parts up. I honestly have no idea how I'd animate something like that properly.

Top

 Post subject: Re: Collision with multijointed spritesPosted: Tue Jun 28, 2016 1:12 pm

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20566
Location: NE Indiana, USA (NTSC)
psycopathicteen wrote:
If there is a platform you can jump through, you'd end up snapping to the platform if you get close to it.

Haunted: Halloween '85 uses soft snapping. If Donny's bottom center point is less than 8 pixels below the top of a platform, his velocity is set slightly upward until he's aligned with the platform. This means hills can be stored as stairs in the level's collision map, giving the illusion of actual slope support.* It also means a 66 pixel vertical leap can put him on a platform 72 pixels above the ground.

* Until you try to jump off a downhill, which I admit is broken in that game.

Top

 Post subject: Re: Collision with multijointed spritesPosted: Tue Jun 28, 2016 2:39 pm

Joined: Sun May 27, 2012 8:43 pm
Posts: 1334
tepples wrote:
* Until you try to jump off a downhill, which I admit is broken in that game.

You can solve this by adding a grace period; when grounded, set a counter. When airborn, decrease the counter if it is greater than zero. Jumping is then allowed if the counter is nonzero.

Donkey Kong Country has an absurdly high period of time where, when the player has transitioned from being grounded to airborn, the player may still perform a jump. I'm not sure this grace period ever expires in DKC, though I haven't experimented with it enough. Level design should be done with this kind of thing in mind (like much of DKC is), but it's an adequate solution to prevent a "why won't he/she jump?!" situation when going downhill. Battletoads has this problem if the player dashes down a hill. A normal-paced walk is fine, though.

In one of my games, I have a grace period of 10 frames, and there is a visual indication of a sweat drop to the side of the player.

Top

 Post subject: Re: Collision with multijointed spritesPosted: Tue Jun 28, 2016 3:58 pm

Joined: Wed May 19, 2010 6:12 pm
Posts: 2751
Wait, you mean sliding a sprite up to the platform was a well known trick? I never even heard of it until this thread.

Top

 Post subject: Re: Collision with multijointed spritesPosted: Wed Jun 29, 2016 11:31 am

Joined: Mon Oct 06, 2014 12:37 am
Posts: 201
tepples wrote:
Haunted: Halloween '85 uses soft snapping. If Donny's bottom center point is less than 8 pixels below the top of a platform, his velocity is set slightly upward until he's aligned with the platform. This means hills can be stored as stairs in the level's collision map, giving the illusion of actual slope support.* It also means a 66 pixel vertical leap can put him on a platform 72 pixels above the ground.

* Until you try to jump off a downhill, which I admit is broken in that game.

I had actually described this slant trick to Nova, quite some time ago, when explaining the benefits of using 8-point collision for optimization.

There's actually an easy way to fix that downhill bug, I forget the particulars though? I'd need to look through some old coding notes.

Top

 Post subject: Re: Collision with multijointed spritesPosted: Wed Jun 29, 2016 1:36 pm

Joined: Wed May 19, 2010 6:12 pm
Posts: 2751
By checking several pixels lower when on ground?

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 14 posts ]

 All times are UTC - 7 hours

#### Who is online

Users browsing this forum: No registered users and 5 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2018 NESdev Competition       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki