Using Hit Areas In Unity?
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
0 ·
Comments
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
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!