Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

SmartSprite and 5.6

Discussion in '2D Experimental Preview' started by hippocoder, Jan 7, 2017.

  1. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Wondering if there will be a preview containing smart sprite based off 5.6? The reason 5.6 is a key turning point is because 2D physics do have breaking changes so we can't use a 5.5x build.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    What breaking changes are those?
     
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    The contact filter stuff that was added, recoded all our player physics to use it, and it works wonderfully.

    And adjusted our sprite shaders (which are custom) as Unity changed how flip works, so this isn't backward compatible either.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    The ContactFilter2D stuff added methods, it didn't change existing ones so it wasn't a breaking change. Any breaking change is a bug. Note that this stuff has been added to 5.6 and bug fixes applied there.

    Oh ... I'm glad you're finding it useful! Any feedback on that would be appreciated!
     
    Last edited: Jan 8, 2017
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Well I'm in love with it. I have a full character controller going just how I like without any raycasts at all. this is powerful, and fast, and physical. I need it for 3D as well though because of this power of having rich contact details filtered just as you like. I no longer need raycasts or hacks. I don't need slow functions like OnCollisionStay. It's in a word, perfect.

    Whoever thought up that thing needs a big thanks. I just hope there's the sense to port the same functionality to 3D, because I do wish to transfer my controller there too. It's spot on for us.

    Heck I don't even need Enter calls much any more, it's improved the performance of my stuff and the quality of it.
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    It was my brain-child so that makes me feel good you find it useful. Was also looking at being able to assign that per Collider2D allowing filtering of contacts automatically but there's a few issues with that, that need to be resolved first.

    This year will see much, much more exposing not only filtering but low-level intersection tests, solvers including island solving, primitive shapes etc. Effectively allowing a 2D simulation away from using Collider2D components but still using the same inherent system they use. Additionaly more fine-grained control over the existing simulation.
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Thanks Melv :)

    But again, please elbow Physx squad / rest of Unity into at least supporting a similar set! It really is just great being able to GetContacts on a filtered list!

    However onto the negatives: I found the whole effector system klunky and platformeffector basically got in my way pretty much non stop, so I don't use it for our pass-through stuff. When doing controllers with fine grain control like I do, it's just way too invasive. I guess it's good for artists or something?
     
  8. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    Thanks for the feedback, the more the better.

    Could you elaborate on both these points?

    When I first came up with effectors I wanted to add those behaviours to colliders but given the component way of doing things in Unity it meant effectors had to be a component. This also meant adding it into the inspector and associating the effector behaviour to a collider component. I experimented with the effector selecting individual components but that wasn't a friendly set-up given that the inspector doesn't really support that kind of connectivity (can drag/drop components but identifying which one isn't obvious). It was decided that a better design was to let the colliders opt-in with a simple check-box. This also meant that there could only be a single effector on each GameObject. I was never really satisifed with the end result but it was the best given the existing set-up of components/inspector.

    I did do some post experimentation with adding an effector behaviour to each collider as some drop-down but exposing properties was difficult and ended-up ugly as heck. Also, it meant those behaviours were not shared when you did require multiple colliders using the same.

    I also intended to write a custom-effector but never got around to it. As part of that was enabling more access to the physics system, particularly existing contacts which is obviously what I've already done.

    One of the next issues is that we cannot perform managed callbacks during the Box2D because the user is allowed to perform any operation including deleting/creating physics objects which would cause Box2D to assert and there's nothing we can do about that so we perform those immediately after Box2D has been updated. This means that if I wanted to allow the user to (say) disable a contact, it would have to be done *after* Box2D has been updated via some callback. This is too later for some operations such as one-way platform where you obviously need to disable contacts as they come in via some algorithm.

    For other types of behaviour though, the new GetContacts/Filter stuff is perfect for writing custom effectors i.e. grab the contacts for a particular collider then perform some addforce (etc) ops to those bodies given some algorithm.

    Anyway, I'd love to hear how you think the platform effector could be improved.
     
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Well the problem with platform effector was even with sides set to 0 and up set to 1, it would still snag in some cases. I gave up with it when I started having problems with it choosing to snap my player to the top (I don't remember why exactly, but just got too frustrated with it in the end).

    So I've resorted to my old hack of just using layers, and when the player is travelling up and in a jump, he's on a layer that can't possibly collide with platforms. I used this fine in the Other Bros, and a couple of other titles but I really wanted to give effectors a chance. Also, as I'm controlling things manually, there's no real use for them. I'm thinking they're more an aid to simulation type games where you have a lot of physics just doing their thing.

    Regarding your problem of design:

    Instead of component based concepts, maybe scriptable object asset based could be used, similar to the new post effects. So you've got your PhysicMaterial, but then you've got your EffectorMaterial and this is an asset you just drag onto a collider. Perhaps that'd elegently solve your problem with components, and enable a wider range of behaviours people could set up. Doubtful I would see use of it myself but I am a mild control freak when it comes to physics.
     
  10. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    Was that fairly recently? I only ask because I completely rewrote it a while back to not use velocity but only use collision normals. If there's any case of it doing something unusual as you describe then please, please contact me, send me a bug report etc. I tend to jump on those things immediately. Maybe I could tempt you back to the component. ;)

    Yes, that was considered last year and it's the way to go to allow association per-collider for sure, even potentially multiple effects to each collider. The question initially was whether having those as sharable assets was better/worse for project clutter. I sense that for a lot of cases, the settings would be the same, particularly for the PlatformEffector. For some of the other effectors, possibly not.

    There's no good reason why it couldn't be tested in the experimental previews; would only take a few days to implement.
     
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Interesting, yeah - it's 5.6 b3 I tested on last. I'll give it a final shot...
    Regarding project clutter, I think you're grossly overestimating how many would be needed, after all these assets, like materials will be a tiny fraction of clutter vs all the sprites, the animators for each sprite, sounds, textures and so on... I can't imagine using more than say, 5?

    Reason I love assets is because they lead to less bugs. There's consistency and far less room for error if you're dropping in predefined properly set up assets.
     
  12. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    To be clear, there wasn't any conclusion that this would be the case, just one consideration of many.

    If you can duplicate it then I'd very much appreciate your reproduction case.
     
  13. Johaness_Reuben

    Johaness_Reuben

    Joined:
    Jan 27, 2016
    Posts:
    253
    On SmartSprite, an experimental version is still quite a while away but in our plans for this year. We're overhauling the design/implementation.
     
  14. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Nice we will test that when the time comes then. I rolled a version myself with Poly2Tri and it was quite a lot of fun. You guys must be planning some nice improvements.
     
  15. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526

    I really appreciate all the hard work done, and the need to make it perfect for all cases, but waiting for years its not really an option that I like so much, so I started using Ferr2d terrain tool, I just try to understand why it takes such a long time for unity to bring out tools like this. I have a feeling it may be better to release them as open source add ons. Like the cinematic effects. At least then people already can start to use them and give feedback.
     
  16. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yep it took me around 3 hours to get it to the point where it is production usable. I can only imagine it's just not urgent and they'd rather just take time over it.

    UE4's approach is to make something and then get the feedback and then replace it. I don't see how it's avoidable.