Search Unity

How can i get runtime vertices in 2d animated sprite?

Discussion in '2D Experimental Preview' started by Yeung, Jul 15, 2019.

  1. Yeung

    Yeung

    Joined:
    May 31, 2013
    Posts:
    2
    Hey guys,
    I have a sprite that was animated by adding bones and geometry with 2D animation version 2.0.0. The sprite is animating great and now i want to add collider to my sprite. But i find that the sprite.vertices are not updated during runtime, which are the initial vertices of the sprite.

    How can i get the vertices positions during runtime?

    Thank you for your help!
     
  2. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    802
    It is not possible with the version of 2D Animation you are using unfortunately.

    We will expose this in a future version.
     
  3. Kidara

    Kidara

    Joined:
    Jul 6, 2017
    Posts:
    16
    Up, is it now possible?
     
  4. MrPaparoz

    MrPaparoz

    Joined:
    Apr 14, 2018
    Posts:
    155
  5. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    354
  6. afakul

    afakul

    Joined:
    Mar 16, 2016
    Posts:
    52
  7. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    441
    We do not have any examples of this. Could you share with us where you are currently stuck @afakul?
     
  8. dikar771

    dikar771

    Joined:
    Oct 30, 2015
    Posts:
    8
    Hey,

    Just tried to get vertices with GetDeformedVertexPositionData() in Update method and assign positions to test spheres: spheres moves in another direction than sprite with real vertices. How can I get global vertices positions?
     
  9. dikar771

    dikar771

    Joined:
    Oct 30, 2015
    Posts:
    8
    Solved. It seems that GetDeformedVertexPositionData() returns localPositions relative to SpriteSkin's transform. Perhaps this should be reflected in the documentation
     
unityunity