Portal 4 BGE

Hey Blenderheads.

Just had a thought as i realized few days ago how to implement something like a portal for Your BGE project.
In order to accomplish it You would need to move the character to a certain location. Then hit I on it and give it a Loc Rot Scale lets say on timeline frame 400.
Then add a cube, and set the character to make an action to play 399 to 400 upon collision between those 2 objects.

Now i can start working on a Portal system for my BGE project and i guess Tick is an Empty action move + overlay scene of Tick itself for OK be “add object” for dropping something that would actuate characters move to different location or load of a different part of the game.

I thought Portal used two identical maps and showed the other map through the portal.

Some games prompt user with a list of towns to where portals could take the character.
It can be more than 2

once again, this is bge, and should be in the bge section.

this issue is a lot more complicated then simply moving locations. you need to take into account orientation and velocities.

if you are thinking portal as in valve, then the portals need to be dynamic in location.

say we have two portals already placed. first we get the orientation of the portal you enter. we get the world velocity in relation to the portal:

enterVel = portalIn.worldOrientation * player.worldLinearVelocity

then we need to get the rotation of the object entering the portal:

enterOri = portalIn.worldOrientation * player.worldOrientation

now we set the player to the new portal:

player.worldPosition = portalOut.worldPosition
player.worldOrientation = portalOut.worldOrientation.inverted() * enterOri
player.localLinearVelocity = enterVel

EDIT:
if you wanted to get fancy like valve portal, you would need to disable collision when contact with portal so you could walk through the wall.

you would also need to not teleport the player until they passed the event horizon.

then the location relative to the portal would be needed:

diff = player.worldPosition - portalIn.worldPosition
enterLoc = portalIn.worldOrientation * diff

exitLoc = portalOut.worldOrientation.inverted() * enterLoc
player.worldPosition = portalOut.worldPosition+exitLoc

This one is a bit touchy to me, i’ve been through one tutorial about portals and it turned out to be one of those prank ones where stuff works for person in video but didn’t work for me and yess yess it involved some coding that i quadriplechecked and stuff still didn’t wrk.

well, its hardly fair to call it a prank. theres lots that can go wrong, even down to some random scene setting.

a simple logic brick solution would be to create an animation of zero location and zero rotation. then upon triggering portal, set player parent to the other portal object then run that animation for one frame, then stop the animation and remove parent. it could be tricky to get the timing right, but it should work

Thanks, i’ve got tonnes on me shoulders to think about. I shall keep that in mind.

Ah. Sorry. I thought you meant ‘Portal’ as in the Portal games made by Valve.

Nope, i was thinking for something like UO’s Moongate ones.