CREATE YOUR WORLD
Players & Characters: Advanced

Side View Example

5min
these are examples of setting side view control step 1 camera view setting set the camera to the side view (this is an example, so please modify the camera setting according to your project ) at this point, the camera's tag should be set to maincamara step 2 inputaction setting by defining a new inputaction that fits the side view, you can control character movements through touch screen select create > input actions and name the file sideview actions move action type pass through move trigger action type button create hierarchy > create empty object and rename it to sideview controller from sideviewcontroller object, select add component and add the player input drag and connect sideview actions that you just created to the actions list change the behavoir to invoke unity events step 3 scripting create a script to control the zepeto character to move from side to side, and have the camera follow, select create > zepeto > typescript and rename it to sideview controller adds the script to the sideviewcontroller object import {zepetoscriptbehaviour} from 'zepeto script' import {playerinput,inputaction} from "unityengine inputsystem" import {callbackcontext} from "unityengine inputsystem inputaction" import {characterstate, zepetocharacter, zepetoplayers, zepetocamera} from 'zepeto character controller' import {camera, quaternion, time, vector2, vector3, waitforendofframe} from "unityengine"; export default class sideviewcontroller extends zepetoscriptbehaviour { public customcamera camera; public cameradistance number = 10; private originspawnpoint vector3 = new vector3( 16, 5,0); private mycharacter zepetocharacter; private startpos vector2 = vector2 zero; private curpos vector2 = vector2 zero; private playerinput playerinput; private touchpositionaction inputaction; private touchtriggeraction inputaction; private istriggered boolean = false; private istouchdown boolean = false; private canmove() boolean { return this istouchdown && !this istriggered; } onenable(){ this playerinput = this gameobject getcomponent\<playerinput>(); } start() { this touchtriggeraction = this playerinput actions findaction("movetrigger"); this touchpositionaction = this playerinput actions findaction("move"); this touchtriggeraction add started((context)=>{ this istriggered = true; this istouchdown = true; }); this touchtriggeraction add canceled((context)=>{ this istriggered = false; this istouchdown = false; }); this touchpositionaction add performed((context)=>{ if(this istouchdown) { this curpos = context readvalueasobject() as vector2; if(this istriggered) { this istriggered = false; this startpos = this curpos; } } }); //turn off zepeto camera zepetoplayers instance onaddedlocalplayer addlistener(() => { zepetoplayers instance localplayer zepetocamera gameobject setactive(false); this mycharacter = zepetoplayers instance localplayer zepetoplayer character; this customcamera transform position = this mycharacter transform position + this originspawnpoint; this startcoroutine(this inputcontrolloop()); }); } private inputcontrolloop(){ while(true) { yield new waitforendofframe(); if (this mycharacter && this canmove()) { var camrot = quaternion euler(0, camera main transform rotation eulerangles y, 0); var movedir = vector2 op subtraction(this curpos, this startpos); movedir = vector2 op division(movedir, 100); if (movedir magnitude > 0) { if(movedir magnitude > 1) movedir normalize(); //left right var optmovedir = new vector3(movedir x, 0, 0); optmovedir = vector3 op multiply(optmovedir, time deltatime 80 ); this mycharacter move(camrot optmovedir); } } } } //follow zepeto character lateupdate() { if(null == this mycharacter) { return; } let characterpos = this mycharacter transform position; //let cameraposition = new vector3(characterpos x this cameradistance, this customcamera transform position y, characterpos z); let cameraposition = new vector3(characterpos x this cameradistance, characterpos y + 1, characterpos z); this customcamera transform position = cameraposition; } } please set up the camera on the inspector before running it