Hello,
I'm not sure what I'm doing wrong here with my Tempest code. I can host and then connect to the host, but when moving around, I can't see the other player moving around when it's moved... Here's the code:
`TV Source
`Code by Jared C. Matthews
`Multiplayer Menu Code************************************************************
set window on
print "1. Enter Stand-Alone Mode"
print "2. Enter Multiplayer Mode"
print
input "Selection: ",singleOrMultiplayer
if singleOrMultiplayer = 2
cls
print "1. Host Game"
print "2. Join Game"
print
input "Selection: ",hostOrJoin
if hostOrJoin = 1
amIHost = 1
cls
input "Please Enter Your IP Address: ",hostIP$
input "Please Enter A Username: ",hostUsername$
hostingSuccess = thost(hostIP$,8,hostUsername$)
if hostingSuccess = 0 then print "Hosting Failed... Exiting..." : wait 2000 : end
if hostingSuccess = 1 then print "Hosting Succeeded!" : wait 2000
endif
if hostOrJoin = 2
amIHost = 0
cls
input "Please Enter the Host's IP Address: ",hostIP$
input "Please Enter A Username: ",myUsername$
joinSuccess = tjoin(hostIP$,myUsername$)
if joinSuccess = 0 then print "Join Game Failed... Exiting..." : wait 2000 : end
if joinSuccess = 1 then print "Joined Game!" : wait 2000
endif
endif
myID = tgetthisid()
`Go to line 107 for other players object setup
`Setup 3D Menu********************************************************************
sync on
sync rate 60
hide mouse
backdrop on
set window on
set display mode 640,480,32
set text font "arial"
set text size 12
`start the collision system
startcollisionpro(000000000,000000000,000000000)
#Constant TYPE_NGC_ELLIP=1
#constant TYPE_NGC_MESH=2
#Constant ELLIP_2_ELLIP=1
#Constant ELLIP_2_POLY=2
#Constant RESP_STICK=1
#Constant RESP_SLIDE=2
#Constant RESP_SLIDE_NO_SLOPES=6
#Constant RESP_SLIDE_NO_GRAV=10
#Constant RESP_SLIDE_NO_ACCEL=18
#Constant RESP_NONE=32
#Constant dyn_NO_RESP=1
#Constant DYN_RESP=2
#Constant DYN_RESP_LOCK=4
#Constant DYN_RESP_LOCK_NOTURN=12
#Constant NCULL_CLOCK 0
#Constant NCULL_COUNTER_CLOCK 1
#Constant NCULL_NONE 2
`setup camera 0
autocam off
set camera range 0,0.1,5000
currentCameraFOV = 62
zoomedInScope = 0
`load and setup main map
load object "towervalley.x",1
position object 1,0,0,0
`load and setup player character
make object cube 2,10
hide object 2
position object 2,300,50,0
pcRotateSpeed# = 3.0
`set up HUD
load image "reticle.tga",1
load image "HUD no weapon.tga",2
load image "HUD radar.tga",3
load image "scope zoomed in.tga",4
`load skybox object
`create marker object
make object sphere 4,0.5
color object 4,rgb(255,0,0)
set object light 4,0
set object ambient 4,1
ghost object on 4
set object transparency 4,1
set object ambience 4,rgb(255,0,0)
flickerState = 0
`set up other players models
for currentOtherPlayerToCreate = 1001 to 1008
make object cube currentOtherPlayerToCreate,10
position object currentOtherPlayerToCreate,300,50,currentOtherPlayerToCreate-950
`if not tplayerexist(currentOtherPlayerToCreate) then hide object currentOtherPlayerToCreate
next currentOtherPlayerToCreate
`assign a group number to each collision group
#constant type_map = 1
#constant type_character = 2
`set how collision each collision group reacts to other collision groups
setcollisionspro(type_character,type_map,ellip_2_poly,resp_slide_no_grav,dyn_no_resp)
`assign each collision object to a collision group
collisiontypepro(1,type_map)
collisiontypepro(2,type_character)
`main loop************************************************************************
do
gosub _show_who_is_connected
gosub _fps_camera_look
gosub _set_up_HUD
gosub _scale_map
gosub _print_screen_fps
gosub _control_player
gosub _add_gravity_to_objects
gosub _cast_ray_with_laser_object
gosub _flicker_laser
gosub _zoom_in_and_out
gosub _send_my_position_to_all_other_players
gosub _recieve_and_impliment_positions_of_all_other_players
`end of main loop*****************************************************************
runcollisionpro()
tsync
sync
loop
stopcollisionpro()
end
_show_who_is_connected:
for currentPlayerToShow = 1 to maxPlayers
if tplayerexist(currentPlayerToShow)
set cursor 0,currentPlayerToShow-900
print tgetplayername(currentPlayerToShow)
endif
next
return
_fps_camera_look:
setobjradiuspro(2,1,10,1)
rotate object 2,camera angle x(0)+(mousemovey()/pcRotateSpeed#),camera angle y(0)+(mousemovex()/pcRotateSpeed#),0
position camera 0,object position x(2),object position y(2)+5, object position z(2)
set camera to object orientation 2
return
_set_up_HUD:
paste image 1,screen width()/2-32,screen height()/2-32,1
paste image 2,385,-30,1
paste image 3,10,340,1
return
_scale_map:
scaleobjectpro(1,1000,1000,1000)
return
_print_screen_fps:
set cursor 0,0
print "FPS: " ; screen fps()
return
_control_player:
if keystate(17) = 1 then moveobjectpro(2,2)
if keystate(31) = 1 then moveobjectpro(2,-2)
if keystate(30) = 1 then moveobjectleftpro(2,2)
if keystate(32) = 1 then moveobjectrightpro(2,2)
return
_add_gravity_to_objects:
setobjgravitypro(2,3)
return
_cast_ray_with_laser_object:
cast_ray(0,4,1,3000)
return
_flicker_laser:
hide object 4 `for now, i don't want to show marker object
return
_zoom_in_and_out:
if keystate(19) = 1 then set camera fov 0,22 : pcRotateSpeed# = 20.0 : zoomedInScope = 1
if keystate(33) = 1 then set camera fov 0,62 : pcRotateSpeed# = 3.0 : zoomedInScope = 0
if zoomedInScope = 1 then paste image 4,0,0,1
if zoomedInScope = 0 then paste image 4,641,481,1
return
_send_my_position_to_all_other_players:
tputint object position x(myID + 1000)
tputint object position y(myID + 1000)
tputint object position z(myID + 1000)
tsetmessageid 1
tsendall
return
_recieve_and_impliment_positions_of_all_other_players:
repeat
positionMessage = tgetmessage()
if positionMessage = 1
whoIsMessageFrom = tgetsender()
xPos = tgetint()
yPos = tgetint()
zPos = tgetint()
if object exist(whoIsMessageFrom)
position object whoIsMessageFrom + 1000,xPos,yPos,zPos
endif
endif
until positionMessage = 0
return
Thank you!
,Jared C. Matthews
"I would rather attempt something big and fail than to never attempt anything at all." -Pastor Michael Youseff