Here's the entire code, commented. I know its a bit sloppy, I got a bit lazy/hungry, just got back from dinner
`Set main app settings
SYNC ON:SYNC RATE 0:AUTOCAM OFF:FOG ON
`Load media/Setup collision
LOAD OBJECT "Portal.X",1
SET OBJECT LIGHT 1,0
POSITION OBJECT 1,1000,0,0
setupObject 1,0,0
LOAD OBJECT "Portal.X",2
SET OBJECT LIGHT 2,0
POSITION OBJECT 2,1000,0,0
setupObject 2,0,0
LOAD OBJECT "map.x",1000
SET OBJECT LIGHT 1000,0
setupObject 1000,0,0
LOAD OBJECT "Character.X",101
`Set cam settings
MAKE CAMERA 1
MAKE CAMERA 2
SET CURRENT CAMERA 0
SET CAMERA VIEW 1,0,0,0,0
SET CAMERA VIEW 2,0,0,0,0
`Click is which mouse button the user is clicking
GLOBAL click
`Start main loop
DO
`Store old coordinates
ox# = CAMERA POSITION X()
oy# = CAMERA POSITION Y()
oz# = CAMERA POSITION Z()
`Handle controls
ROTATE CAMERA WRAPVALUE(CAMERA ANGLE X()+(MOUSEMOVEY()*.1)),WRAPVALUE(CAMERA ANGLE Y()+(MOUSEMOVEX()*.1)),0
IF KEYSTATE(17) = 1 THEN MOVE CAMERA 5
IF KEYSTATE(31) = 1 THEN MOVE CAMERA -5
`Update click
click = MOUSECLICK()
`Store new coordinates
x# = CAMERA POSITION X()
y# = CAMERA POSITION Y()
z# = CAMERA POSITION Z()
`If the user presses the left or right mouse button
IF click > 0 AND click < 3
`Get a point 2000 units infront of them
MOVE CAMERA 2000
lx# = CAMERA POSITION X()
ly# = CAMERA POSITION Y()
lz# = CAMERA POSITION Z()
MOVE CAMERA -2000
`Using the point we just obtained, position/rotation the appropriate portal to the normal's position/angle
`depending on if an ntersection occured or not.
Make_pOrtal(1000,click,x#,y#,z#,lx#,ly#,lz#)
ENDIF
`Rotate each portal camera to the user's cam rotation
ROTATE CAMERA 1,CAMERA ANGLE X(),CAMERA ANGLE Y(),CAMERA ANGLE Z()
ROTATE CAMERA 2,CAMERA ANGLE X(),CAMERA ANGLE Y(),CAMERA ANGLE Z()
`Grab each portal cam's image
SET CAMERA TO IMAGE 1,1,512,512
SET CAMERA TO IMAGE 2,2,512,512
`Texture the opposite portal with each portal cam's image
TEXTURE OBJECT 1,2
TEXTURE OBJECT 2,1
`Position the character model at the cam's position
POSITION OBJECT 101,x#,y#,z#
`Update the portal objects (needed since theyre moving around)
updateObject 1
updateObject 2
`Check for intersection with each portal. If one occurs, position user at opposite portal.
A# = INTERSECT OBJECT(1,ox#,oy#,oz#,x#,y#,z#)
IF A# > 0
POSITION CAMERA OBJECT POSITION X(2),OBJECT POSITION Y(2),OBJECT POSITION Z(2)
ROTATE CAMERA OBJECT ANGLE X(2),OBJECT ANGLE Y(2),OBJECT ANGLE Z(2)
MOVE CAMERA 6
ROTATE CAMERA 0,CAMERA ANGLE Y(),0
ENDIF
B# = INTERSECT OBJECT(2,ox#,oy#,oz#,x#,y#,z#)
IF B# > 0
POSITION CAMERA OBJECT POSITION X(1),OBJECT POSITION Y(1),OBJECT POSITION Z(1)
ROTATE CAMERA OBJECT ANGLE X(1),OBJECT ANGLE Y(1),OBJECT ANGLE Z(1)
MOVE CAMERA 6
ROTATE CAMERA 0,CAMERA ANGLE Y(),0
ENDIF
`Rotate the character model to the cam's rotation.
ROTATE OBJECT 101,CAMERA ANGLE X(),CAMERA ANGLE Y(),CAMERA ANGLE Z()
SYNC
LOOP
`This function will position the appropriate portal (specified by click) and rotate it as well.
FUNCTION Make_pOrtal(Object,Dynamic,X1#,Y1#,Z1#,X2#,Y2#,Z2#)
C# = intersectObject(Object,0,X1#,Y1#,Z1#,X2#,Y2#,Z2#,1)
IF C# <> 0
NewX# = getStaticCollisionX()
NewY# = getStaticCollisionY()
NewZ# = getStaticCollisionZ()
NormX# = getCollisionNormalX()
NormY# = getCollisionNormalY()
NormZ# = getCollisionNormalZ()
POSITION OBJECT Dynamic,NewX#+NormX#/10,NewY#+NormY#/10,NewZ#+NormZ#/10
POINT OBJECT Dynamic,NewX#+NormX#,NewY#+NormY#,NewZ#+NormZ#
POSITION CAMERA click,NewX#+NormX#/10,NewY#+NormY#/10,NewZ#+NormZ#/10
POINT CAMERA click,NewX#+NormX#,NewY#+NormY#,NewZ#+NormZ#
ENDIF
ENDFUNCTION C
`This is needed for sparky's dll to work, since it requires the memblock dll.
DELETE MEMBLOCK 1
I uploaded the media too, feel free to use it wherever (I know its not anything good but just gotta get that out there, roalty free and whatnot).
Projects: Online CTF Game | Newcommer's Guide to FPS's