Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411507 Posts in 69374 Topics- by 58429 Members - Latest Member: Alternalo

April 26, 2024, 05:56:55 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)2D Platformer Collisions - Passing through platforms momentarily?
Pages: [1]
Print
Author Topic: 2D Platformer Collisions - Passing through platforms momentarily?  (Read 858 times)
PogueSquadron
Level 1
*



View Profile WWW
« on: July 03, 2017, 01:33:21 PM »

I try not to spend too much time on a gamedev problem because I want to just get something that works well enough. Well, my little prototype works well enough but there's something that always bothers the hell out of me. From what I understand, it has something to do with how Unity handles collisions.

Basically, when I jump and land on a platform, my character will very (almost unnoticeably) pass through the platform and then bounce back up. Correct me if I'm wrong, but this is because Unity basically checks to see that an object has gone through something, and if it does, pops that object back into position.

Is there any relatively simple way to just have my character STOP when he lands? It sounds like it should be the most common sense thing in the world, no? Thank you all so much in advance for any help.

This is the issue in question. Here, my character is landing from a jump, and you can see him briefly passing through the ground before he pops back up.

Logged
turnipinrut
Level 0
**



View Profile
« Reply #1 on: July 05, 2017, 01:25:46 AM »

Did you try setting the collision detection to continuous on the players rigidbody2D?  By default it's set to Discrete which is more performative but less accurate.
Logged
nanoblit
Level 0
*



View Profile
« Reply #2 on: July 05, 2017, 10:19:18 AM »

set Edit > Project Settings > Time > Fixed Timestep to a lower value. (e.g. 0.01)
Not exactly sure why it happens though. I remember reading an explanation somewhere, but it either went over my head or I forgot. Tongue
« Last Edit: July 05, 2017, 10:45:07 AM by nanoblit » Logged
0xDEADBAAD
Level 0
**

Hooker with a penis


View Profile WWW
« Reply #3 on: July 13, 2017, 12:52:38 PM »

set Edit > Project Settings > Time > Fixed Timestep to a lower value. (e.g. 0.01)
Not exactly sure why it happens though. I remember reading an explanation somewhere, but it either went over my head or I forgot. Tongue

This is generally a bad idea and definitely an overkill for this kind of issue.

Continuous collision detection for the player should do the trick.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic