BUAT DUNIAMU
Pemain & Karakter: Lanjutan

Contoh Tampilan Kuartal

4min
kontrol karakter zepeto dapat disesuaikan untuk menggunakan sistem input baru unity alih alih v pad ini adalah contoh pengaturan kontrol tampilan kuartal langkah 1 pengaturan tampilan kamera atur kamera sebagai tampilan kuartal (ini adalah contoh, jadi silakan modifikasi pengaturan kamera sesuai proyek anda ) pada titik ini, tag kamera harus diatur ke maincamara langkah 2 pengaturan inputaction dengan mendefinisikan inputaction baru untuk tampilan kuartal, anda dapat mengontrol gerakan karakter melalui layar sentuh pilih buat > input actions dan atur nama file sebagai quarterviewactions gerak tipe aksi lewati gerak pemicu tipe aksi tombol setelah membuat hierarchy > buat objek kosong, ubah nama file menjadi quarterviewcontroller dari objek quarterviewcontroller, pilih tambah komponen dan tambahkan input pemain seret dan sambungkan aksi quarterview yang baru saja anda buat ke daftar aksi ubah perilaku menjadi panggil acara unity langkah 3 penulisan skrip tulis skrip yang menghitung arah gerakan karakter melalui input layar sentuh pilih buat > zepeto > typescript dan ganti namanya menjadi pengendali tampilan kuartal menambahkan skrip ke objek quarterview controller 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 quarterviewcontroller extends zepetoscriptbehaviour { 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; } } }); zepetoplayers instance onaddedlocalplayer addlistener(() => { zepetoplayers instance localplayer zepetocamera gameobject setactive(false); this mycharacter = zepetoplayers instance localplayer zepetoplayer character; 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(); var optmovedir = new vector3(movedir x, 0, movedir y); optmovedir = vector3 op multiply(optmovedir, time deltatime 80 ); this mycharacter move(camrot optmovedir); } } } } }