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
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