08.09.2019 Views

Progettazione e Sviluppo di un Multiplayer Online Game su Reti Peer-to-Peer

Alma Mater Studiorum Universit`a degli Studi di Bologna Facolta` di Scienze Matematiche, Fisiche e Naturali Corso di Laurea in Scienze di Internet Tesi di Laurea in Laboratorio di Programmazione Internet

Alma Mater Studiorum Universit`a degli Studi di Bologna
Facolta` di Scienze Matematiche, Fisiche e Naturali
Corso di Laurea in Scienze di Internet
Tesi di Laurea in Laboratorio di Programmazione Internet

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.7. ESEMPI PRATICI 59<br />

Può capitare infatti che <strong>un</strong> Bullet <strong>di</strong> <strong>un</strong> Player non rilevi la collisione con <strong>un</strong><br />

Character in movimen<strong>to</strong> appartenente ad <strong>un</strong> altro Player perchè <strong>un</strong>o dei due<br />

(o entrambi) sono soggetti ad <strong>un</strong>’elevata latenza a tal p<strong>un</strong><strong>to</strong> che le notifiche<br />

dei rispettivi movimenti vengano ricevute con <strong>un</strong> sincronizzazione temporale<br />

tale da bypassare la Collision Detection tra il Bullet ed il Character. O<br />

viceversa, che venga rilevata <strong>un</strong>a collisione con <strong>un</strong> Character che in realtà si<br />

trova già fuori portata <strong>di</strong> tiro.<br />

Facendo riferimen<strong>to</strong> alla Figura 2.28, si possono in<strong>di</strong>viduare alc<strong>un</strong>i problemi<br />

com<strong>un</strong>i: Il Player A ha <strong>un</strong> Lag relativamente basso (60ms), contrariamente<br />

a B e C che hanno <strong>un</strong> Lag relativamente al<strong>to</strong> (rispettivamente 120ms<br />

e 240ms).<br />

In T1 il Player A spara <strong>un</strong> Bullet. In ques<strong>to</strong> istante il proiettile è presente<br />

solamente nel Data Layer e Layer View del <strong>Peer</strong> A.<br />

In T2 il Player B riceve la notifica <strong>di</strong> creazione Bullet, e conseguentemente<br />

crea la propria copia del componente logico, e quin<strong>di</strong> il relativo ogget<strong>to</strong><br />

grafico nel proprio Layer View. Inoltre inizia a muovere il proprio Character<br />

nella <strong>di</strong>rezione del Bullet <strong>di</strong> A. Nel frattempo in A il proiettile si è mosso <strong>di</strong><br />

qualche step. Il Player C, invece, è ancora fermo allo sta<strong>to</strong> <strong>di</strong> gioco <strong>di</strong> T0.<br />

In T3 il Bullet <strong>di</strong> A ed il Character <strong>di</strong> B continuano la propria corsa, mentre<br />

in C è finalmente gi<strong>un</strong>ta la notifica <strong>di</strong> creazione Bullet.<br />

In T4, nel Layer View del Player B, si palesa <strong>un</strong>a collisione tra il Bullet <strong>di</strong> A<br />

ed il Character <strong>di</strong> B. Cosa che invece non avviene nel Layer View del Player<br />

A, poiché il movimen<strong>to</strong> <strong>di</strong> B è in ritardo <strong>di</strong> qualche step. Dal momen<strong>to</strong> che,<br />

per <strong>un</strong>a scelta implementativa, è il ComponentScript dell’Owner del Bullet<br />

ad effettuare la Collision Detection, cioè A, tale collisione viene ignorata e<br />

non ha ripercussioni quin<strong>di</strong> <strong>su</strong>llo sta<strong>to</strong> <strong>di</strong> gioco.<br />

Il Player C inizia a muovere il proprio Character, ma tale informazione per<br />

il momen<strong>to</strong> rimane confinata al <strong>su</strong>o <strong>Peer</strong>.<br />

In T5 è C a rilevare <strong>un</strong>a collisione tra il Bullet <strong>di</strong> A ed il Character <strong>di</strong> B, ma<br />

per gli stessi motivi elencati nel precedente p<strong>un</strong><strong>to</strong>, ciò non ha ripercussioni

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!