Search Feedback

1392
votes
Completed

A Physics2D.IgnoreCollision function is vital for proper one-way platformers in Unity2D.

2D

-

-

With Unity's new 2D tools, a very common thing people will be attempting is to make platformers, and an extremely fundamental part of platforming are platforms which can only be interacted with from the top.

In 3D, this would be fairly easily achieveable, either by using a one way mesh or by placing an empty GameObject on each edge of the object in question (or using the scale) to find the lowest point of the object, and determining whether that point is higher or lower than the platform they're trying to board. At that point, you could simply use Physics.IgnoreCollision to refuse collisions between two.

http://docs.unity3d.com/Documentation/ScriptReference/Physics.IgnoreCollision.html

However, this function does not exist in 2D, and we don't have one way edge colliders. There are cheap kludges like using triggers to remove velocity, but obviously at high velocities this will result in objects burying themselves in your platforms, and strange physics once things fall on top of each other.

This function would also be useful for a plethora of events, like players colliding with platforms/enemies but not each other, and bullets not harming players. For now layers can be used, but this is a cheap fix.

So if you would implement a Physics2D.IgnoreCollision function, this would resolve a lot of important issues for platformers.

Thanks.

Response-avatar

ElvisAlistar

May 28, 2014

Available in 4.5

Comments (23)

  1. C04f5a2eef402d2b14ca5e6280fb4e68?d=mm

    MelvMay

    May 27, 2014 15:10

    This method was added to 4.5 which is now released. Also as mentioned above, the rope joint is now exposed within the DistanceJoint2D when it is set to max-distance-only.

  2. 7f9fb04146d525d8ce2a995c975157fe?d=mm

    lupidan

    Apr 10, 2014 11:20

    For complex platformers, this is really needed. I find myself switching the layer of an object between two layers, so one collides and the other doesn't :(

  3. C1dcbd0adfcb8162f4fdb38436675d38?d=mm

    crazybovine

    Apr 09, 2014 22:31

    +1 : presolve & postsolve, and ability to selectively ignore contacts (or tweak for some effects). Essential imho, this is a showstopper for porting our game to unity as our choice of engine :-(

  4. 2f20690dafb576c3840b2b560c7304a6?d=mm

    lukad

    Mar 30, 2014 10:19

    Holy crap. How can feature be missing?

  5. B331b9532b8cee0f9c06a117b5848c5a?d=mm

    Elecman

    Mar 19, 2014 02:31

    This will be added in Unity 5:
    http://www.youtube.com/watch?feature=player_embedded&v=tSfakMeW0lw

  6. 336b22566509abf240785b57f02dd74f?d=mm

    brampratowo

    Mar 16, 2014 13:08

    Yes, I Agree.

  7. 9bb744b59dc43dad53e5a1a82cb1aa99?d=mm

    NikolaiT

    Mar 13, 2014 03:53

    I agree 100% on this, I am currently working on a game where the lack of this function has caused me significant issues in which an object with a rigidbody2d instantiates another object also with a rigidbody2d at its exact transform.position. As you can imagine the results are far from ideal even with Physics2d.IgnoreLayerCollision (which doesn't work in this case).

  8. B1b86da74dfa5674943e9ec7359b00e2?d=mm

    Exilim

    Mar 02, 2014 23:09

    This is not optional, but utterly essential for any proper 2D Project. Not having this adds an enourmous amount of extra effort into each project and greatly reduces the development speed which unity otherwise offers.

  9. 883fee6af2b448d531bcdc85bcfe937c?d=mm

    mu-kow

    Feb 13, 2014 13:59

    Something like OnCollisionPreSolve2D is exactly what i need! It would also be nice to have access to the moment of inertia too. Right now i have to use OnTriggerEnter/Stay2d and solve for the contact manifold myself which is imperfect and slow. The convex polygon decomposition exposed would help too :(

  10. 6aa54045c9564a5df84f0b1d93a13137?d=mm

    nopogo

    Feb 11, 2014 07:57

    This totally breaks my latest project, a must have to add (pretty please with sugar on top)

Your opinion counts

Help us make things better. Share your great idea for improving Unity or vote for other people’s.

Log in to post a new idea

Categories

All

(4537)

2D

(64)

Assets

(429)

Audio

(81)

Editor

(1094)

General

(378)

Graphics

(334)

GUI

(164)

Input

(93)

Licensing

(65)

Networking

(53)

Physics

(160)

Platforms

(246)

Runtime

(87)

Scripting

(568)

Terrain

(79)

Web Player

(83)