It is currently Sun Oct 22, 2017 5:55 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: Tue Jun 28, 2016 8:15 am 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2295
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
 Profile  
 
PostPosted: Tue Jun 28, 2016 9:31 am 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3074
Location: Nacogdoches, Texas
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
 Profile  
 
PostPosted: Tue Jun 28, 2016 10:23 am 
Offline

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


Top
 Profile  
 
PostPosted: Tue Jun 28, 2016 12:06 pm 
Offline
User avatar

Joined: Sun May 27, 2012 8:43 pm
Posts: 1306
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
 Profile  
 
PostPosted: Tue Jun 28, 2016 12:21 pm 
Offline

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


Top
 Profile  
 
PostPosted: Tue Jun 28, 2016 12:27 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10066
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
 Profile  
 
PostPosted: Tue Jun 28, 2016 12:40 pm 
Offline
User avatar

Joined: Sun May 27, 2012 8:43 pm
Posts: 1306
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
 Profile  
 
PostPosted: Tue Jun 28, 2016 12:56 pm 
Offline

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

I guess this isn't important for multijointed sprites.


Top
 Profile  
 
PostPosted: Tue Jun 28, 2016 12:57 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10066
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
 Profile  
 
PostPosted: Tue Jun 28, 2016 1:12 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
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
 Profile  
 
PostPosted: Tue Jun 28, 2016 2:39 pm 
Offline
User avatar

Joined: Sun May 27, 2012 8:43 pm
Posts: 1306
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
 Profile  
 
PostPosted: Tue Jun 28, 2016 3:58 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2295
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
 Profile  
 
PostPosted: Wed Jun 29, 2016 11:31 am 
Offline
User avatar

Joined: Mon Oct 06, 2014 12:37 am
Posts: 183
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
 Profile  
 
PostPosted: Wed Jun 29, 2016 1:36 pm 
Offline

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 6 guests


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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group