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

Requested feature, sprite sockets

Discussion in '2D Experimental Preview' started by Khena_B, Aug 30, 2016.

  1. Khena_B

    Khena_B

    Joined:
    Aug 21, 2014
    Posts:
    273
    Hey,

    There's a useful feature that UE4 has which seems to be missing from Unity, in UE4 we can add sprite sockets in the sprite editor, which defines a location that we can use to, for example, spawn a particle. That socket can be positioned to match each sprites in an animation, Let's say we create a "Gun" socket, we can align it with the gun of each sprites, this makes it easy to know where the gun is located at all times.
     
  2. ColossalPaul

    ColossalPaul

    Unity Technologies

    Joined:
    May 1, 2013
    Posts:
    174
    Would creating a GO as a child of the Sprite be sufficient as the attachment point? You can save this setup as a Prefab. What is missing from this prefab technique?
     
  3. Khena_B

    Khena_B

    Joined:
    Aug 21, 2014
    Posts:
    273
    It wouldn't be sufficient as the sprite is animated and the elements of that sprite such as the gun, are moving every frames, to be able to spawn a projectile from the barrel of the gun i'd have to animate the child Gameobject so that it would precisely follow the gun during each frames of each animations.

    Sockets could easily be created and positioned on each sprite frames, then used as dynamic locations for instantiating prefabs and so on, i was actually surprised that Unity didn't have this feature.
     
    Last edited: Aug 30, 2016
  4. Khena_B

    Khena_B

    Joined:
    Aug 21, 2014
    Posts:
    273
    I've decided to try and just animate a Gameobject to follow all my animations, it almost works but the issue is that my sprite animations are playing at a low framerate but the Gameobject's animated position is moving every game frames so it doesn't quite follow the sprites, the Gameobject's position curves would have to look like stairs instead of nice rounded hills, i haven't found a way to do that with curves.
     
    Last edited: Apr 1, 2017
  5. Khena_B

    Khena_B

    Joined:
    Aug 21, 2014
    Posts:
    273
    Setting the animation curves to "Both tangents > Constant" solved my problem and it now follows properly.

    Still, "sprite sockets" would be a more user friendly way of doing that.

    Keep up the good work.
     
  6. Khena_B

    Khena_B

    Joined:
    Aug 21, 2014
    Posts:
    273
    It doesn't work with my jumping animation which uses 5 different animations of a single frame and a blend tree to change between them depending on the vertical velocity, the Gameobject position is also being blended gradually which causes the same issue i've demonstrated above.
     
  7. Jay-Pavlina

    Jay-Pavlina

    Joined:
    Feb 19, 2012
    Posts:
    195
    I agree this would be a useful feature. They're usually referred to as attach points. You can look at 2D Tookit's documentation to see how they tackled the issue.

    I guess you would just add another sprite editor "mode" that would allow placing points and naming them? Since you added colliders to sprites, this seems like a natural addition.