CREATE YOUR WORLD
Scripting
Tag & Layer
7min
you can use the tag and layer functions from unity for developing a world tag you can use the tag function the same way you used it in unity ❗️ caution you can use up to 64 tags below is an example code for setting a tag for a zepeto character import { zepetoscriptbehaviour } from 'zepeto script'; import { zepetocharacter, zepetoplayer, zepetoplayers } from 'zepeto character controller'; export default class playertag extends zepetoscriptbehaviour { private zepetocharacter \ zepetocharacter; start() { zepetoplayers instance onaddedlocalplayer addlistener(() => { this zepetocharacter = zepetoplayers instance localplayer zepetoplayer character; // set player tag this zepetocharacter gameobject tag = "player"; }); } } below is an example code for using the tag function import { zepetoscriptbehaviour } from 'zepeto script'; import { gameobject } from 'unityengine'; export default class tagexample extends zepetoscriptbehaviour { start() { let findobj = gameobject findgameobjectwithtag("customtag"); if (findobj != null) { console log(`name ${findobj name}`); } } } 📘 unity tag information https //docs unity3d com/manual/tags html https //docs unity3d com/manual/tags html layer you can use the layer function the same way you used it in unity ❗️ caution you can use layers number 20 to 27 the following is an example code to set a layer for the zepeto character import { zepetoscriptbehaviour } from 'zepeto script'; import { zepetocharacter, zepetoplayer, zepetoplayers } from 'zepeto character controller'; export default class playerlayer extends zepetoscriptbehaviour { private zepetocharacter \ zepetocharacter; start() { zepetoplayers instance onaddedlocalplayer addlistener(() => { this zepetocharacter = zepetoplayers instance localplayer zepetoplayer character; // set player layer this zepetocharacter gameobject layer = 20; }); } } the following is an example code for using the layer function import { zepetoscriptbehaviour } from 'zepeto script'; import { camera, input, physics, raycasthit } from 'unityengine'; export default class layerexample extends zepetoscriptbehaviour { update() { if (input getmousebuttondown(0)) { let ray = camera main screenpointtoray(input mouseposition); let ref = $ref\<raycasthit>(); let layermask = 1 << 20; if (physics raycast(ray, ref, 100, layermask)) { let hitinfo = $unref(ref); console log(`name ${hitinfo collider gameobject name}`); } } } } 📘 unity layer information https //docs unity3d com/manual/layers html https //docs unity3d com/manual/layers html