Examining Portal's Teleportation Code
Gamasutra is running a story deconstructing the mechanics of Portal's teleportation programming. They present a snippet of Portal's code and a downloadable demo. They ran another article in this series earlier this year with an analysis Mario Galaxy's unique take on physics. We've discussed the development of Portal in the past.
"Teleport mechanics in video games are nothing new. Puzzles from the original Gauntlet were memorable -- and more than likely, that wasn't the first game to use teleportation as a gameplay mechanic. The difference between Portal and all those that came before it is that Portal's teleportation acts as a frictionless tube between point A and point B. Physics are still hard at work inside the frictionless tube. Instead of simply repositioning an object from point A to point B, the player enters point A with full velocity and exits point B with the same speed, but moving in a new direction."
Update: 8/26 at 19:37 by SS: Dan notes that the code was not directly from Portal; it was written to approximate Portal's physics.
Your mom has a frictionless tube.
First post?
Regardless it's a lot better than quantum teleportation.
Well, back to rejecting software patent applications.
But... can they telefrag?
I just love the sound of 2 bodies trying to occupy the same space at the same time in the morning... or afternoon... or evening...
Don't blame me, I voted for Kodos
>>Physics are still hard at work inside the frictionless tube. Instead of simply repositioning an object from point A to point B, the player enters point A with full velocity and exits point B with the same speed, but moving in a new direction."
Should be "Speedy thing goes in; speedy thing comes out."
I want to see the nautical version, Porthole.
You can't talk about Wikipedia's flaws on Wikipedia
if they'd chosen the Discworld version of teleportation: two objects have to be teleported simultaneously in opposite directions, and the weight difference determines the exit speed of the lighter object.
You can do that with 'bzflag' portals. Take a jump through the portal or with the 'wings' flag. Then you appear at the other end like SG-1 stargate. Spins and backward movement work as well.
Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
A well made 2D Flash version of Portal:
http://portal.wecreatestuff.com/portal.php
Any thoughts on a nice little compare and contrast of the 'teleportation physics' between Prey and Portal?
"Quote me as saying I was mis-quoted." -Groucho Marx
These two were my favorites:
http://www.mcescher.net/images/relativity.jpg (1953)
and
http://www.mcescher.net/images/houseofstairs.jpg (1951)
The code is a lie!
Ok, sorry...
When you shoot a mime, do you use a silencer?
Reading that article makes me want to play Portal through again.
--sigh-- at least it won't take long.
Life is like a web application. Sometime you need cookies just to get by.
the only person not absolutely obsessed with portal? video games use physics.
projectile force in rise of the triad? doom? every fragging quake? I liked this game better when it was called narbacular drop.
Good people go to bed earlier.
Speaking of, whens he gonna put a new album out?
Porting Portal's portal code?
The difference between Portal and all those that came before it is that Portal's teleportation acts as a frictionless tube between point A and point B. Physics are still hard at work inside the frictionless tube. Instead of simply repositioning an object from point A to point B, the player enters point A with full velocity and exits point B with the same speed, but moving in a new direction.
Are you fucking kidding? What's not completely obvious about this algorithm that should be Slashdot-front page worthy? I mean, it's fucking mind blowingly obvious, of course it keeps the velocity and translates it, how else could it do what it does? I can understand why it would be relevant to do a coding tutorial on the subject, but that's about as newsworthy as a Bresenham line drawing algorithm tutorial. TFS looks just like a "hey let's talk about how some super popular game is super awesome and post about it on a high traffic website".
You just got troll'd!
According to portal theory in some place, this comment is the first!
If you could put a portal on a fast falling object, when it lands on you while you are standing still would you have momentum at the other of the portal or would you just poke through since the portal has the initial momentum? (IE nonplayer movement being different than player movement)
What would that say about your reference frame? Could you use that to distinguish which of two objects had "universal frame" movement? That'd be kinda neat, theoretically, but it'd be way more interesting to be able to put a portal on a crate hanging from a crane, then make the crate fall while standing under it to catapult yourself from a low position.
the comments go in the code
Somebody using Ogre3D has been working on a portal like project for nearly a year and has made pretty damn good progress for somebody who was new to game programming:
http://www.ogre3d.org/phpBB2/viewtopic.php?t=37376
He also has a blog which seems quite lacking though.
This space is not for rent.
I don't know... without RTFAing this seems to be a pretty straightforward problem.
If you wish to "teleport" an object, find the objects vector, find the difference from the portal's normal, move said object to front of connecting portal, dot the difference vector you got from before with the new portal's normal, keep velocity/acceleration constant.
Now, there's more to be done with making it look like the player is actually travelling through the portal. But, the movement itself seems quite simple...
-SaNo
Could we use these highly advanced computer programs for these portal tubes on the tubes that power the internet?
this isn't even coded correctly in blitz3d... .001 "blitz3d distances" away from the wall.
... my copy of blitz3d is lost but there definitly right about using it to create quick 3d stuff
When you align the portals they flicker because blitz3d cannot handle 3d objects right on top of each other. The easiest fix for this is to move the portals
In the game, GlaDOS says "momentum is conserved through the portal." Assuming our physical system is the character, momentum definitely is not conserved. Neither is energy. The description "the player enters point A with full velocity and exits point B with the same speed, but moving in a new direction" is exactly correct: a textbook example of momentum non-conservation. However, what drives the exciting "flinging" effect, which makes Portal's teleportation so unique, isn't just momentum redirection. It's that you instantly obtain the potential energy of your exit location. This new potential energy can be converted back into kinetic energy, increasing your speed...mix in a little momentum redirection at the portals then wash, rinse, repeat. Although GlaDOS describes the game physics incorrectly, there is a game walkthrough where the programmers do describe it correctly. If you take any physics courses from me, you can expect to see some Portal questions on future quizzes :) Nice article overall.
i\hbar\dot{\psi}=\hat{H}\psi
Instead of simply repositioning an object from point A to point B, the player enters point A with full velocity and exits point B with the same speed, but moving in a new direction.
In other words, speedy thing goes in, speedy things comes out?
------
"And may your days be long upon the earth."
There's a fair amount of fake physics involved. Properly, the parts of the character on one side of the portal should have the gravity and momentum of that inertial frame, and as the character passes through the portal, the new frame should begin to act on the character. But the sample code in Gamasutra treat the character as a single rigid body.
It's a neat problem to make the physics correct as the character moves though a portal. It could certainly be done, even for ragdoll characters. From a gameplay perspective, it would drive players nuts. To make the gameplay tolerable, the designers of this game added a pseudo-force that tends to align the character with the local vertical. Otherwise, characters would have execute proper parachute landing falls when moving through a gravity vector change.
Character physics almost has to be fake. Trying to drive a real car via a game pad is very difficult, and trying to drive a human body via a game pad is worse.
http://www.phespirit.info/momus/19980102.htm
When all you have is a hammer, everything looks like a skull.
Portal exploits portal rendering technology - a technique for graphics optimisation which incidentally allows you to take a given map layout and provide a different subjective layout for the player. It's actually a fairly trivial problem to do the portals themselves, as most graphics engines these days should have portalling built in. All of the interesting physics comes in when they start making it work as gameplay, for example by giving portal entrances "push" or "pull" to steer players into and out of them. The article is a good description of how to make a game that behaves a bit like Portal, but it's got nothing to do with that game's actual physics.
No kidding!!! What do you say at this point?
Ahhh, good ol' Momus. Does he ever change that eyepatch?
Halo 3's teleporters do this...I had loads of fun in forge making portals to cliff edges in front of 'human propulsifiers'
On second thought, let's not go to the internet. 'Tis a silly place.
Speaking of, whens he gonna put a new album out?
Are you talking about M.C. Escher who designed the crazy staircase house? Or David Bowie, who lives there?
The enemies of Democracy are
the cake is a lie
No kidding. The whole "frictionless tube" thing is just thinking too hard about it. Yes, instead of simply repositioning an object from point A to point B, you also take the normal of both holes and change the direction of the velocity. That's it. It solves the same problem and produces the exact same result without doing physics for a frictionless tube.
A polar bear is a cartesian bear after a coordinate transform.
"that wasn't the first game to use teleportation as a gameplay mechanic...the player enters point A with full velocity and exits point B with the same speed, but moving in a new direction"
Sounds like they re-invented (ms)Pacman(jr)
Portal's physics go *way* beyond what the article implies.
Article basically says: it's not a simple teleport, direction of movement and momentum are preserved.
This is far too much of an oversimplification. Portal was probably a technically difficult game to code for - mostly due to collision physics. The problem is that something does not instantly teleport from one end of the portal to another. You can have an object on BOTH sides of the portal. This makes physics calculations very difficult, since you essentially have a single object of a small finite size, colliding with different objects across the room, affected differently by gravity, etc.
If I get the right gist from the developer commentary in the game, their solution was the CLONE the two sides of the portal in a mini physics-only environment and run the simulation there.
Definitely much more complex than the article.
I got a great blow-job last weekend. It was like she was making out with my dick.
It was wonderful.
And when you were done, did you type 'afk' and light a cigarette?
"I like to lick butts!" by MobileTatsu-NJG (#32700246) (Score:5, Informative)
I wonder if that's where the cake got to...
Move all sig!
I played that one all the way through too. It seemed to me that the portals worked a little differently than in 3d portal.
What was confusing to me in the 3d portal was how your orientation on exiting the portal would change based on the orientation you shot the portal from.
They ARE out to get you simply because They are in it for themselves and they don't care about you.
i actually thought that the portal travel method seemed more like wormhole travel, something liek stargates in Stargate, than teleportation, as we are accustomed to in the startrek generation (geek reference).
Wormholes create a direction connection between two points in space/time that allow energy and matter to pass through directly. In the case of the portal game, you can actually see through the wormhole in both directions (rather than what looks like a 'water' event horizon", even to the point of looking at your self in both sides of the event horizon.
As I understand the physics of teleportation, the device would deconstruct the matter into energy, sends it from point a to point b along a 'path', and recontructs it at point b.
thoughts? :)
dwight.
The article talks about the easy part, and not the hard part. If you listened to the game's commentary (or just tried using your brain, maybe) turns out it's not obvious at all.
For instance, how do you handle mechanics where an object can collide with something while it's half-way through the portal? Or two things that are half-way through a portal colliding with each other? How do you write graphics for something that can display an object in two places, two environments at once, as well as see-through holes to different parts of space?
Teleportation is at hand. Maybe even quantum teleportation!
Wasn't the first game to have teleportation Zork?
XYZZY
Started neat but quickly degenerated in to something all to typical with flash games: You have to have really fast reflexes and figure you the logic apparent only to the designer. Neat technically, but the gameplay needs work.
And with that, I give you "Approaching Perimelasma" by Geoffrey A. Landis: http://www.infinityplus.co.uk/stories/perimelasma.htm
These two were my favorites:
http://www.mcescher.net/images/relativity.jpg (1953)
and
http://www.mcescher.net/images/houseofstairs.jpg (1951)
The last one could be done in prey with the adjustable gravity vector. Now as for the Duke 3D engine. We lost that whole sector ability when we went with true 3D.
I'm not a pheasant plucker
I'm a pheasant plucker's son
And I'm only plucking pheasants
Till the pheasant plucker comes!
Didn't Asteroids have prior art on this..? :)
"Slow down, Cowboy! It has been 3 years, 7 months and 26 days since you last successfully posted a comment."
Unreal had better-made portals in 1998. Too bad we don't see more of those in today's games.
His programming may certainly work to duplicate the effect of the Portal, but the physics portrayed by the game world are a little different.
First, it's not a tube, it may have an effective 'depth' of Zero. It certainly doesn't exceed 1cm at the worst case. Find a spot in the game with a corner, you can arrange things so you can see yourself from both Portals. It's very apparent at that point that their is either no 'depth' to the Portal, or it's so small you really can't perceive it in the game.
Second, objects passing through do not change direction. Their direction and velocity are the same as when they entered. To an outsider, it appears as though they change, but that is an illusion. Just remember that the Portal is a connection through space. Relative to the object passing through, it hasn't changed direction, rather everything else changed location. As far as it's concerned (or her, if you really want to stress the game character)a simple continous vector was followed. Though it may have been a ballistic or falling arc, and the forces of gravity may have shifted direction, the subject was simply following a basic newtonian trajectory through the local spacetime. (A spacetime with a doorway or wormhole in it.)
Like I was saying, the authors coding of the software to duplicate this effect was fine, but it's not the same thing as the physics it represents in the game. After all, even our most complex simulations of reality take very liberal and unrealistic shortcuts to make things happen that do not represent the physics involved.
(It's like someone watching original Star Trek and proclaiming that the Transporters use a photon based array transfer because I can see the Christmas lights they used in the transporter pad...)
What the hell? the original unreal had the same portal technology as "portal" so it is nothing new techwise. All they did new was base the gameplay around it.
Pac-Man had the slide door....
Prior art?
http://www.patentstorm.us/patents/5414801/description.html
So the transporter didn't preserve the rocket's momentum - it just put the rocket at a new location, and the game then resumed moving the rocket forward.
From a engine coding point of view, i fail to see how there's any difference.
In both cases, you have a vector attached to an object which describes how an object move :
- you can call it "trajectory" for shots
- you can call it "momentum" for portal
but technically it's just plain stupid "speed" vector. As in "derivative of the position" (= how the position is updated between each turn).
Eventually, if it's not a rocket, it will also obey to an acceleration (most of the time : gravity. But it can be buoyancy).
In both situation, all you have to do for any object entering a teleport, is simply change the current coordinate of the object, and eventually perform a transformation on the speed vector if both teleport end point aren't facing the same direction.
From a coding point of view portal doesn't introduce anything new for the physics that wasn't already done by any of all the multiple game that allow shooting through a portal or *jumping* through a teleport.
The new thing are the rendering engine (not all engine can easily render see-through portals - due to the way the work, Duke 3D's and Descent [portal based] and Wolfenstein and Doom [raycasting] could do them, but Quake 1 & 2 [BSP polygons] can't)
and the gameplay (before portal, teleporting thing other than the player was a fun by-product of how teleport work and can enable a couple of giggles. Portal in contrast has all its puzzle based around throwing object through portals)
"Sufficiently advanced satire is indistinguishable from reality." - [Tips: 1DrYakQDKCQ6y52z6QbnkxHXAocMZJE61o ]
Portal breaks it!
Say I have my entrance portal at the base of a cliff and my exit portal at the top of the cliff. At the bottom, I have zero energy. Once I enter the portal and end up hovering for that split second at the top of the cliff, I have quite a lot of potential energy. Doesn't work!
Because the duke engine is basically a (2D) portal renderer.
The world is represented as a series of convex sectors.
Then sectors are connected together by sharing 1 side. The renderer works by painting the wall of the current sector. When a sector edge isn't a wall but a connection to another sector, the renderer start painting the opposite wall for the connected sector.
The good thing is that, as you mention, it is possible to design things that can't be laid on an actual 2D map, simply by allowing sectors to be connected in more original ways (is possible to build staircases which point to 2 different sectors, it's possible to build strange design were 3 square rooms are all connected together, etc...)
This approach also come with support for see-through portals and mirrors for free (a mirror is simply a sector connected back to itself). Although I don't remember if they actually used the see-through ability in Duke.
The other good thing (the main reason it was done this way) is that it speeds up considerably the render speed as the system knows very precisely which walls are visible. (If i remember correctly, Descent used a similar approach but in full 3D - in order to consider for rendering only the couple of room connected to the current one).
"Sufficiently advanced satire is indistinguishable from reality." - [Tips: 1DrYakQDKCQ6y52z6QbnkxHXAocMZJE61o ]
The dwarf with a huge dick fucks the shit out of our heroine and it seems like the best sex in her life...
"Haven't you ever seen such a big toy, Frau? Especially if a dwarf has it, right? Haven't you been fucked by such a big dick? Well, check it out!"
I was overwhelmed by curiosity and fear. His dick looked really luring but it was so big it could literally tear me apart. But⦠I just wondered what I would feel with such a cock inside me?
His hands spread my hips.
"See you're leaking girl! I'm gonna show you what a real hardcore fuck is like!"
He entered my snatch with his dick. At one thrust! When I regained consciousness I felt his dick screw me. The frictions seemed to echo in every single cell of my body. I was crying and... trying to impale myself more on his prick. It hurt but it was so awesome! What a wonderful penis he had! C'mon boy, fuck me harder! I was cumming...
He told me to turn round and get on my knees. His shaft got back to my stretched pussy, getting deeper in my womb. He was trying to reach for my tits with his short hands. I was trying to help him with it... But I just couldn't move, his stem didn't let me move. Well, seemed he realized it was mission impossible and he just started squeezing and caressing my hips and my ass. Wait a minute... he wasn't caressing my butt. He was lubricating it!
"You shouldn't do this sir..."
"Oh, yes, I should Frau!"
Hardly had I had rest after that wonderful orgasm as his stem entered my asshole⦠it was more than I could take, both literally and figuratively. He was drilling my ass getting deeper in my rectum. Man, those were brand new sensations, the feeling when my butt lost virginity two days ago was nothing in comparison with the dwarf's wild ass ramming.
The orgy was so exhausting for my body I lost consciousness for a couple of minutes. When I opened my eyes my lover was caressing my boobs. I felt like my butt hurt, guess he'd torn it apart... But there was no time for self-pity; I had to get back to work. My client told me to suck his shaft off. Man, the dick was so huge I just couldn't get it in my throat. Well, I'd better use my cunt...
He was lying on his back I mounted his member carefully and slowly. I started riding the dick, the dwarf moaned approvingly trying to screw me deeper. I stopped him gently and took full control over the tempo and the depth of penetration. That felt much better, for both of us. He was smiling, grinning, giggling, and moaning.
Damn, my ass hurt... I was probably too absorbed in my own sensations and didn't notice him push me downwards and enter me very-very deep. Ohhh God!
When I opened my eyes, my client was zipping up his pants. He gave me several crispy bills and said:
"Thank you so much Frau Lotta! You're the first woman for the last three years who managed to satisfy me. Sorry for hurting you."
I couldn't even reply, all I could do was moan and blink my eyes. Yeah, it was the most unforgettable fuck for my entire life! My holes were swollen, red and aching. I had to get up and go to the hall but I couldn't move.
Loren knocked on the door.
"Hey don't move Liz... it's ok. Frau Dort said it's enough for you for today. You're the first who managed to please babe Henrich!"
"What???"
"Well, you saw his pecker. He can't find a woman to have sex with, no street whore or brothel slut agrees to sleep with him. You were great, girl! We were watching your show on TV in the hall. There were all the girls and all clients there. You've earned a hell of money today, babe!"
"What about your show, Loren? How many hours did you spent with Schulz? Seven? More?"
Loren screwed up her eyes, caressing her boobs automatically.
"You know Liz, I'm getting married. To Schulz!"
WHAT??!!
"How come?" I asked, still not believing my ears.
"Well, we just thought we could make a nice couple -- a scientist and a whore. He will teach and I will please. We'll marry as soon as I'm through
Pac-Man, however, never changed his acceleration, so the speed at which he entered and exited any portal was never in issue, it was constant. Additionally, the teleportation happened off-screen -- in Portal, you can actually look THROUGH the portal out to the other side. In summary, Portal is more complicated than Pac-Man by many degrees of magnitude because the portals themselves entail more variables.
+1, Touche.
I'm making a note here, huge success!
Mon chien, il n'a pas du nez. Comment scent-il? TrÃs mauvais!
The coolest part about Portal is that you don't feel like you're teleporting, you feel like you're just going through a hole in the wall.
Mr. Period: Nine is the one that's right by ten!
Nine: One day I will kill him. Then, I will be Ten.
Google it if you don't understand that.
That is hilarious. I watched The Labryinth just a couple of days ago for the first time.