Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Games Entertainment

Examining Portal's Teleportation Code 278

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.
This discussion has been archived. No new comments can be posted.

Examining Portal's Teleportation Code

Comments Filter:
  • Damn! (Score:5, Insightful)

    by khendron ( 225184 ) on Tuesday August 26, 2008 @03:09PM (#24754901) Homepage

    Reading that article makes me want to play Portal through again.

    --sigh-- at least it won't take long.

  • WTF (Score:5, Insightful)

    by 4D6963 ( 933028 ) on Tuesday August 26, 2008 @03:13PM (#24754951)

    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".

  • Re:WTF (Score:3, Insightful)

    by 77Punker ( 673758 ) <spencr04 @ h i g h p o i n t.edu> on Tuesday August 26, 2008 @03:23PM (#24755079)

    The physics of the teleportation are pretty boring, but the fact that you can see through the portals and have an object go halfway through a portal are unusual.

    I don't care enough about programming games to RTFA, but that could be something worth talking about. Chances are it's not what they're talking about, though.

  • Re:WTF (Score:3, Insightful)

    by 4D6963 ( 933028 ) on Tuesday August 26, 2008 @03:55PM (#24755513)
    Haha nice one, I didn't think about that ;-). Don't pay attention to the other posters, Slashdot is crowded with people insensitive to even the most blatant sarcasm.
  • Re:WTF (Score:3, Insightful)

    by 4D6963 ( 933028 ) on Tuesday August 26, 2008 @04:08PM (#24755731)
    You're pretty much missing the point, or at least your comparison is quite flawed. The Mona Lisa isn't obvious, not anyone who wanted to a woman's portrait came up with the Mona Lisa. And neither is Portal as a whole. But the algorithm behind the teleportation in Portal is flat out obvious. Like, really, anyone can come up with it when they're thinking of teleportation. The idea behind the game is what's admirable and ingenuous, not the little necessary and obvious algorithm.
  • Re:am i (Score:5, Insightful)

    by FiloEleven ( 602040 ) on Tuesday August 26, 2008 @04:08PM (#24755747)

    When it was ugly, buggy, and short?

    Narbuncular Drop was a great student project showing off a new idea, and I'm glad it's still available to play with. Neglecting the gameplay polish, puzzle depth, and environmental detail improvements that went into Portal is, IMO, a gross error in judgment.

    You forgot to end with "get off my lawn" =)

  • No kidding (Score:3, Insightful)

    by Moraelin ( 679338 ) on Tuesday August 26, 2008 @04:15PM (#24755841) Journal

    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.

  • by p0tat03 ( 985078 ) on Tuesday August 26, 2008 @04:20PM (#24755909)

    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.

  • Not really (Score:3, Insightful)

    by Sycraft-fu ( 314770 ) on Tuesday August 26, 2008 @05:29PM (#24756743)

    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.

  • by daver00 ( 1336845 ) on Tuesday August 26, 2008 @06:00PM (#24757061)

    So on a slightly off topic note, does that invalidate the theory of 'wormholes' for some hypothetical FTL space travel? Surely, were it possible to create a wormhole in spacetime, you could set up a perpetual motion machine that works exactly like you describe, thus violating the second law. A nice simple thought experiment, I like it.

  • by DrYak ( 748999 ) on Tuesday August 26, 2008 @09:55PM (#24759415) Homepage

    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)

  • by Dr. Cody ( 554864 ) on Tuesday August 26, 2008 @09:56PM (#24759423)

    Actually, there's a "conservation whipping boy" in a hidden room of each level getting pummeled against the wall of his cell to account for inconsistencies arising from use of the gun.

  • Re:Portal (Score:3, Insightful)

    by SanityInAnarchy ( 655584 ) <ninja@slaphack.com> on Wednesday August 27, 2008 @12:50AM (#24760957) Journal

    unless you can actually model the natural laws of physics, you're going to have to use hacks to fake most of it.

    True.

    My point here is that Quake was a milestone in avoiding such hacks -- most levels built in most modern FPSes could have been built in Quake, it's just that the performance would suck. These levels really couldn't have been built in Duke3D.

    dropping down from that vent shaft in Hollywood Holocaust at the beginning of Episode 1: L.A. Meltdown, it totally blew my mind how "realistic" this game was.

    Yeah, I remember that -- it was my first FPS. The explosions surrounding that were pretty cool, too -- camera shaking and everything.

    Of course, it was also my first abuse of cheats. DNKROZ.

    so the vertical layering issue is strictly limited to the map engine, and inside every "room" you had a fully 3d environment.

    Well, you have a fully 3D column of air. I still find it quite a lot more interesting to explore a fully 3D environment -- Half-Life was probably the next game that blew my mind. (Though, to be honest, it was probably Counter-Strike first.)

  • Re:Portal (Score:3, Insightful)

    by TheThiefMaster ( 992038 ) on Wednesday August 27, 2008 @08:34AM (#24763489)

    The point is that you actually walk INTO the portal, you don't teleport on contact. The physics in portal has been written to allow you to essentially walk into the wall the portal is on.

    Perhaps a better way of putting it would be that there is continuity of collision detection across the portal.

    No attempts to imitate it have done this, they've just done the traditional "teleport on contact", which means that there is an obvious jump as you touch the portal. Including in TFA's attempt.

Stellar rays prove fibbing never pays. Embezzlement is another matter.

Working...