Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1324672 Posts in 59727 Topics- by 50941 Members - Latest Member: JanDavid

December 11, 2017, 07:23:04 am

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Problem with one way platfforms
Pages: [1]
Print
Author Topic: Problem with one way platfforms  (Read 1076 times)
Little Miracles Games
Level 0
**



View Profile WWW
« on: September 13, 2016, 07:37:30 am »

Hello,

We are experiencing a bug in our game and we’re hoping the dev community to help us with it. In this case, our platforming game needs one-way platforms. Unity has them integrated in the engine, so that’s fine. But when our character is about to get to the top of them, with his collider already overlapping the one that acts as the platform but almost over it, he’s pushed upwards unnaturally until he gets completely over. It looks like a clumsy teleport which even makes you jump a little once in the platform.

To solve it, we try to made our own one-way colliders. We put a trigger under the platform that makes the collider of the character a trigger on entering, so it won’t collide with the collider above, and makes the collider hard again when he’s out. Even with that, we’re having the exact same problem. It may be worth noting that our character is moving constantly, so it may affect Unity’s physics.

That’s why we’re asking, in case you have a solution or experience in this subject.

More info:
  • We’re using Unity 5.4.0f3.
  • We’re using layers to indicate to the character what is ground, wall, etc.
  • Our character has a 2D circle collider and some raycasts to detect which kind of surface the collider is touching (since 
  • walls make you bounce automatically, etc.).
  • When we tried the one-way method provided by Unity, not our attempted solution, we used a box collider 2D and a platform 
  • effector with “Use One Way” activated with the layer: Ground.



Thanks!



Logged

bateleur
Level 10
*****



View Profile
« Reply #1 on: September 14, 2016, 12:23:08 am »

What appears to happen in your video clip is that the character passes through the platform from below without interaction until its Y velocity crosses zero. At this point it collides with the platform and is therefore pushed out of the collision volume.

This is, of course, not what you want. However, it is what Unity's one way colliders do, because they have to process collisions on a frame by frame basis. You know that the character "came from below", but all Unity sees is a character that is moving downwards and therefore eligible to collide.

The solution you've tried to adopt sounds as though it ought to work. If you're having the "exact same problem" then clearly something's gone wrong with your implementation, since if your character's collider really were still a trigger at that point it clearly couldn't get pushed anywhere, because triggers never do!

I'd recommend putting in some visual indicator of when the collider is set to a trigger and when it isn't. That might make it slightly clearer what's going wrong.
Logged

Zorg
Level 9
****



View Profile
« Reply #2 on: September 14, 2016, 05:21:36 am »

I had this problem, too. Unity's one-way-platforms did not behave like expected at all. I think i used something like "On collision, check if the collision should occur. If not, ignore the collision". I likely used https://docs.unity3d.com/ScriptReference/Physics2D.IgnoreCollision.html but i'm not sure... i'll have a look at my code, later.
Logged
Zorg
Level 9
****



View Profile
« Reply #3 on: September 16, 2016, 10:09:48 am »

Sorry, i forgot to answer.

I did not solve the problem globally, but it worked for my case: only clouds, no walls, box colliders only.

      ____
     |    |
     |____|         _[P]_
                     | |   _____
                          |     |
            ______        |     |
    _______|______|_______|_____|__
   |                               |
   |                               |


The hands and feet of the player character are actually raycasts, let's call them a, b, c and d from left to right. I set IgnoreCollision to true if a or d hit something, else if b or c hit something i set IgnoreCollision to false (always with the collider from the raycast hits).

Edit: The flying block has to be initialized with IgnoreCollision true, iirc.
« Last Edit: September 16, 2016, 10:21:28 am by zorg » Logged
Ripityom
Level 0
**



View Profile
« Reply #4 on: May 22, 2017, 01:33:00 pm »

I had the same problem, however my rigidbody passing throu did not change direction.
For some reason the problem went away after enabling Use One Way Grouping, not sure why tho, I had only one dollider on my player...
Logged
Meteorbyte
Level 0
**



View Profile WWW
« Reply #5 on: May 23, 2017, 11:28:19 am »

Try adding a Physic material to your colliders. You haven't got any there. Many of these "clogging" and "sticking" problems on collisions get solved very neatly by adding a Physic material to your colliders.

Create a few Physic materials, and make sure all of your GameObjects have them in their colliders.

Here's a neat tutorial about it (watch after minute 06:00 for the Physic materials explanation):



Logged

Check out WOODPUNK, a fast-paced action game with procedural WEAPON generation, hundreds of enemies to battle and fully destroyable enviroments:
http://steamcommunity.com/sharedfiles/filedetails/?id=895158311

Follow us on twitter: https://twitter.com/meteorbyte_stu/
Teknokommari
Level 0
**


View Profile WWW
« Reply #6 on: May 24, 2017, 12:05:07 am »

Where's the pivot point of your character?

It could be that the Platform Effector uses the transform.position to determine whether the character is above the platform in which chase the pivot should be at the feet of the character. With Sprites you could just change the pivot to bottom on character sprites and adjust the position of the collider(s) to match the new position of the sprite.

You might have to modify the pivot of the platform sprite as well if you want the collision happen only if character is above the platform not just half-way through it.
« Last Edit: May 24, 2017, 12:10:22 am by Teknokommari » Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic