CREATE YOUR WORLD
Players & Characters: Advanced

FPS/TPS View Example

3min
these are examples of setting fps/tps control step 1 fixing camera position to fix the camera in tps, go to zepetoplayers > zepetocamera > zoom and set the min and max value to same set the look offset y value to 0 1 to fix the camera in fps, go to zepetoplayers > zepetocamera > zoom and set the min and max value to 1 set the look offset y value to 0 1 step 2 scripting add a script that applies the rotation of the camera to the rotation of the character add a script to correct the rotation of the character by receiving the camera rotate input (ondragevent) import { zepetoscriptbehaviour } from 'zepeto script'; import { zepetoplayers, zepetocharacter, zepetoscreentouchpad, zepetocamera } from 'zepeto character controller'; import { vector3, time, quaternion} from 'unityengine'; import { zepetoinputcontrol } from 'rootnamespace'; export default class tpscontroller extends zepetoscriptbehaviour { private zepetoscreenpad zepetoscreentouchpad; private mycharacter zepetocharacter; private myinputcontrol zepetoinputcontrol; private mycamera zepetocamera; awake() { this myinputcontrol = new zepetoinputcontrol(); } start() { this myinputcontrol enable(); zepetoplayers instance onaddedlocalplayer addlistener(() => { this mycamera = zepetoplayers instance localplayer zepetocamera; this mycharacter = zepetoplayers instance localplayer zepetoplayer character; this zepetoscreenpad = zepetoplayers instance gameobject getcomponentinchildren\<zepetoscreentouchpad>(); this zepetoscreenpad ondragevent addlistener(deltavector => { console log(`\[ondragevent] ${deltavector tostring()}`); // the rotation of the camera is corrected according to the rotation of the character zepetoplayers instance zepetocamera transform rotatearound(this mycharacter transform position, vector3 up, deltavector x time deltatime 80); }); }); } update() { if ((null == this mycharacter) || (null == this mycamera)) { return; } const lookaxisrot = quaternion lookrotation(this mycamera cameraparent forward); const projrot = vector3 projectonplane(lookaxisrot eulerangles, vector3 right); // match the rotation of the character with the forward direction of the camera this mycharacter gameobject transform rotation = quaternion euler(projrot); } }