so hier noch mal eine vieleicht komplizierte frage :
ich verzweifle grade daran wie ich die objekte( vor allem geschosse) im meinem 2d multiplayer schooter synchen soll
bis jetzt hab ich (jetzt im konkreten beispiel geschosse) das ganze vollgendermaßen aufgebaut:
1.wenn schuss von spieler 1 erstellt gibt er das mit den write data befehlen an spieler 2 an er schreibt folgende werte :
1. x und y koordinaten 2. richtung (0 links oder 1 rechts)
2. dieser erstellt dann an den übermittelten koordinaten ein objekt namens Bullet_02_mp
3 die erstellte kugel holt sich dann die richtung und fliegt los
4. treffer werden bei beiden spielern gezeigt und berechnet der schaden jedoch nur bei einem spieler (jeder für seinen eignen spieler)
so das ganze geht auch gut allerdings nur solange die beiden instancen des spils entweder auf der selben machine oder im selben lan hängen sobalt
ich hamachi zwischenschalte (online ip´s funktionieren ja nicht ) hab ich das problem das der andre spieler furchtbar zu laggen anfängt und somit die berechnung des schadens nicht mehr richtig stattfindet und das spiel also desynchron wird (bei einem spiler trifft die kugel beim andren nicht )
weiß irgendjemand der vieleicht schon erfahrung damit hat wie man so ein problem umgeht
ps vieleicht hilfts ja hier mal 'n ausschnitt aus dem controller_mp_bullets der erstellt jewalls die kugeln vom andren
Spoiler anzeigen
und hir mal aus einer der beiden multiplayer bullets
Spoiler anzeigen
und noch n (kleiner) ausschnitt aus dem player (mp)
Spoiler anzeigen
ich verzweifle grade daran wie ich die objekte( vor allem geschosse) im meinem 2d multiplayer schooter synchen soll
bis jetzt hab ich (jetzt im konkreten beispiel geschosse) das ganze vollgendermaßen aufgebaut:
1.wenn schuss von spieler 1 erstellt gibt er das mit den write data befehlen an spieler 2 an er schreibt folgende werte :
1. x und y koordinaten 2. richtung (0 links oder 1 rechts)
2. dieser erstellt dann an den übermittelten koordinaten ein objekt namens Bullet_02_mp
3 die erstellte kugel holt sich dann die richtung und fliegt los
4. treffer werden bei beiden spielern gezeigt und berechnet der schaden jedoch nur bei einem spieler (jeder für seinen eignen spieler)
so das ganze geht auch gut allerdings nur solange die beiden instancen des spils entweder auf der selben machine oder im selben lan hängen sobalt
ich hamachi zwischenschalte (online ip´s funktionieren ja nicht ) hab ich das problem das der andre spieler furchtbar zu laggen anfängt und somit die berechnung des schadens nicht mehr richtig stattfindet und das spiel also desynchron wird (bei einem spiler trifft die kugel beim andren nicht )
weiß irgendjemand der vieleicht schon erfahrung damit hat wie man so ein problem umgeht
ps vieleicht hilfts ja hier mal 'n ausschnitt aus dem controller_mp_bullets der erstellt jewalls die kugeln vom andren
Create Event:
set variable crea_bullet to 0
Step Event:
if global.host is equal to 0
execute code:
if global.host =0{
crea_bullet=mplay_data_read(110)}
if crea_bullet is equal to 1
execute code:
if global.host =0{
bulletx=mplay_data_read(111)
bullety=mplay_data_read(112)}
create instance of object bullet02_red_mp at position (bulletx,bullety)
execute code:
mplay_data_write(110,0)
if global.host is equal to 1
execute code:
if global.host =1{
crea_bullet=mplay_data_read(210)}
if crea_bullet is equal to 1
execute code:
if global.host =1{
bulletx=mplay_data_read(211)
bullety=mplay_data_read(212)}
create instance of object bullet02_blue_mp at position (bulletx,bullety)
execute code:
mplay_data_write(210,0)
Draw Event:
at relative position (0,0) draw the value of: crea_bullet
set variable crea_bullet to 0
Step Event:
if global.host is equal to 0
execute code:
if global.host =0{
crea_bullet=mplay_data_read(110)}
if crea_bullet is equal to 1
execute code:
if global.host =0{
bulletx=mplay_data_read(111)
bullety=mplay_data_read(112)}
create instance of object bullet02_red_mp at position (bulletx,bullety)
execute code:
mplay_data_write(110,0)
if global.host is equal to 1
execute code:
if global.host =1{
crea_bullet=mplay_data_read(210)}
if crea_bullet is equal to 1
execute code:
if global.host =1{
bulletx=mplay_data_read(211)
bullety=mplay_data_read(212)}
create instance of object bullet02_blue_mp at position (bulletx,bullety)
execute code:
mplay_data_write(210,0)
Draw Event:
at relative position (0,0) draw the value of: crea_bullet
und hir mal aus einer der beiden multiplayer bullets
Create Event:
execute code:
if global.host=0
richtung=mplay_data_read(113)
if global.host=1
richtung=mplay_data_read(213)
if number of objects player_01 is Equal to 1
if richtung is equal to 0
set the horizontal speed to -10
else
set the horizontal speed to 10
play sound bullet02; looping: false
if number of objects player_online is Equal to 1
if richtung is equal to 0
set the horizontal speed to -10
else
set the horizontal speed to 10
play sound bullet02; looping: false
else
destroy the instance
Collision Event with object floor01:
destroy the instance
create instance of object funken at relative position (0,0)
Collision Event with object bullet02 blue:
for other object: destroy the instance
destroy the instance
create instance of object funken at relative position (0,0)
Collision Event with object kiste:
for other object: if leben is smaller than 999
destroy the instance
create instance of object funken at relative position (0,0)
Collision Event with object Fass:
for other object: if leben is smaller than 999
destroy the instance
create instance of object funken at relative position (0,0)
Collision Event with object player_online:
destroy the instance
create instance of object funken at relative position (0,0)
for other object: set variable leben relative to global.bullet02_schaden
execute code:
if global.host=0
richtung=mplay_data_read(113)
if global.host=1
richtung=mplay_data_read(213)
if number of objects player_01 is Equal to 1
if richtung is equal to 0
set the horizontal speed to -10
else
set the horizontal speed to 10
play sound bullet02; looping: false
if number of objects player_online is Equal to 1
if richtung is equal to 0
set the horizontal speed to -10
else
set the horizontal speed to 10
play sound bullet02; looping: false
else
destroy the instance
Collision Event with object floor01:
destroy the instance
create instance of object funken at relative position (0,0)
Collision Event with object bullet02 blue:
for other object: destroy the instance
destroy the instance
create instance of object funken at relative position (0,0)
Collision Event with object kiste:
for other object: if leben is smaller than 999
destroy the instance
create instance of object funken at relative position (0,0)
Collision Event with object Fass:
for other object: if leben is smaller than 999
destroy the instance
create instance of object funken at relative position (0,0)
Collision Event with object player_online:
destroy the instance
create instance of object funken at relative position (0,0)
for other object: set variable leben relative to global.bullet02_schaden
und noch n (kleiner) ausschnitt aus dem player (mp)
execute code:
if global.host=1
{mplay_data_write(11,x)
mplay_data_write(12,y)
mplay_data_write(13,sprite_index)
mplay_data_write(14,image_speed)
mplay_data_write(15,leben)}
if global.host=0
{mplay_data_write(21,x)
mplay_data_write(22,y)
mplay_data_write(23,sprite_index)
mplay_data_write(24,image_speed)
mplay_data_write(25,leben)}
if relative position (0,1) is collision free for Only solid objects
set the gravity to 1 in direction 270
else
set the gravity to 0 in direction 270
if vspeed is larger than 12
set the vertical speed to 12
if tod is equal to 0
if leben is smaller than 1
create instance of object dead at relative position (0,0)
destroy the instance
set variable tod to 1
set Alarm 0 to 30
Key Press Event for <Space> Key:
if look is equal to 0
execute code:
if global.host = 1
{mplay_data_write(110,1)
mplay_data_write(111,x-13)
mplay_data_write(112,y+2.51)
mplay_data_write(113,0)}
if global.host = 0
{mplay_data_write(210,1)
mplay_data_write(211,x-13)
mplay_data_write(212,y+2.51)
mplay_data_write(213,0)}
if global.host is equal to 1
create instance of object bullet02 at relative position (-13,2.51)
if global.host is equal to 0
create instance of object bullet02 blue at relative position (-13,2.51)
else
execute code:
if global.host = 1
{mplay_data_write(110,1)
mplay_data_write(111,x-13)
mplay_data_write(112,y+2.51)
mplay_data_write(113,1)}
if global.host = 0
{mplay_data_write(210,1)
mplay_data_write(211,x-13)
mplay_data_write(212,y+2.51)
mplay_data_write(213,1)}
if global.host is equal to 1
create instance of object bullet02 at relative position (11,2.51)
if global.host is equal to 0
create instance of object bullet02 blue at relative position (11,2.51)
if global.host=1
{mplay_data_write(11,x)
mplay_data_write(12,y)
mplay_data_write(13,sprite_index)
mplay_data_write(14,image_speed)
mplay_data_write(15,leben)}
if global.host=0
{mplay_data_write(21,x)
mplay_data_write(22,y)
mplay_data_write(23,sprite_index)
mplay_data_write(24,image_speed)
mplay_data_write(25,leben)}
if relative position (0,1) is collision free for Only solid objects
set the gravity to 1 in direction 270
else
set the gravity to 0 in direction 270
if vspeed is larger than 12
set the vertical speed to 12
if tod is equal to 0
if leben is smaller than 1
create instance of object dead at relative position (0,0)
destroy the instance
set variable tod to 1
set Alarm 0 to 30
Key Press Event for <Space> Key:
if look is equal to 0
execute code:
if global.host = 1
{mplay_data_write(110,1)
mplay_data_write(111,x-13)
mplay_data_write(112,y+2.51)
mplay_data_write(113,0)}
if global.host = 0
{mplay_data_write(210,1)
mplay_data_write(211,x-13)
mplay_data_write(212,y+2.51)
mplay_data_write(213,0)}
if global.host is equal to 1
create instance of object bullet02 at relative position (-13,2.51)
if global.host is equal to 0
create instance of object bullet02 blue at relative position (-13,2.51)
else
execute code:
if global.host = 1
{mplay_data_write(110,1)
mplay_data_write(111,x-13)
mplay_data_write(112,y+2.51)
mplay_data_write(113,1)}
if global.host = 0
{mplay_data_write(210,1)
mplay_data_write(211,x-13)
mplay_data_write(212,y+2.51)
mplay_data_write(213,1)}
if global.host is equal to 1
create instance of object bullet02 at relative position (11,2.51)
if global.host is equal to 0
create instance of object bullet02 blue at relative position (11,2.51)

Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von meav33 ()