Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Please limit one question/topic per post.
Please provide the following details depending on types of question

▼ For question regarding Editor, please provide:
- Live2D Software Version: (e.g. Cubism Editor 3.1.02, Euclid Editor 1.2.02)
- OS & Version: (e.g. Windows 10, macOS HighSierra)
- PC Model: (e.g. MacBookPro 2017)
- Graphics Specifications: (e.g. GeForce GTX 950M)
- Memory: (e.g. 8GB)
- Illustration Software used: (e.g. Photoshop, ClipStudio, SAI)
- Attach screenshot or capture video to show your problem:
---------------------------
▼ For question regarding SDK, please provide:
- For us to reproduce the issue you wish to inquire about, please provide either a minimum project file which has the issue. or specific instructions on how to reproduce the issue.
- Types and version of Cubism SDK you are using.
---------------------------
▼ For question regarding Cubism Software License,
For issues related to purchasing, your order, license key, and subscription, please contact us via contact form:
https://www.live2d.com/en/contact/contact_form

Using Hit Areas In Unity?

edited August 2015 in Archive
Hi!
I would like to do a few things with hit areas in unity.

I'm using the scripts from SampleApp1.

I want to make the objects created with the DrawHitArea function visible in the editor (maybe as a gizmo?).
I want to be able to change their transform (position and scale) with an UpdateHitArea function for hit areas that move when a parameter changes.

My problem is that I don't know how to access the objects created with DrawHitArea and I don't know how to move the object to the new position of the hit area.
Are the created objects GameObjects or something else? How are they named when they are created?

Hoping someone can help :smile:
Tagged:

Comments

  • Hit Area on a Live2D model can only be edited on Modeler. In Modeler, Hit Area is made by placing a dummy invisible drawable object with a specific ID to be treated as a Hit Area in Unity. Therefore the only way to access Hit Area is to directly edit these objects in Modeler.

    For your reference, Hit Area settings are controlled in “hit_areas” of a model.json

    "hit_areas":
    [
    {"name":"head", "id":"D_REF.HEAD"},
    {"name":"body", "id":"D_REF.BODY"}
    ],
    => name is used to identify hit area in game (e.g. head, body)
    => id is used to identify corresponding drawable object’s ID (see photo).

    When a screen is tapped, the tapped coordinate values are passed to LAppModel.HitTest() to determine whether or not a Hit Area is tapped. It is determined programmatically as opposed to a new object being crated like Mesh Collider in Unity.

    Also note that in SampleApp1, Hit Area is determined with a dummy drawable object in rectangle. So if you with to design specific shapes for Hit Area object, you ought to obtain the coordinate values of the object and reflect it in your codes.

    You can also refer to this document:
    https://translate.google.com/translate?sl=ja&tl=en&js=y&prev=_t&hl=ja&ie=UTF-8&u=http://sites.cybernoids.jp/cubism2/&edit-text=&act=url

  • Hi Tod!
    Thanks for the response.

    Sorry for the late reply. It seems that DrawHitArea can work to make hit areas visible but
    it slows everything down dramatically. Still good to have something that works for debugging purposes.
    I'll try write a DrawHitArea type function that draws gizmos instead, in case it might work better than 'DrawRect'.

    Thanks again!
Sign In or Register to comment.