- Home /
Turning a Corner in 2.5d Platformer
So, I decided to give Unity a shot and I've run into my first major hurdle. Right now, I have a basic 2.5d platformer, but I'd like to be able to turn a corner and have the camera follow.
My first idea was to have a global vector that would decide along which axis the character would move as well as which way the camera should point from and it would be updated by individual scripts on each platform which would define which axis should be used when the character is over it.
Then, I decided that it would probably be much more efficient if I didn't have to add a script for each and every platform (there are sure to be many). So, I thought that it might be possible to define regions within which the global vector should have a certain value. Finally, I realized that since I'm still just a beginner with Unity, there's probably something I'm missing that would make the process a whole lot less convoluted. Any ideas?
Answer by Philipp · Dec 08, 2012 at 09:15 AM
There are probably many viable ways of doing something like that, but I'd try the following:
Set up your different regions as GameObjects with BoxColliders set as triggers. Rotate these GameObjects so that their x- and y-axes are aligned with how the player would move within the region. When the player enters a region, store the region GameObject she's in. When the player moves, move her along the right and up axes of the region's Transform.
You could also push/pop regions onto a stack when the player enters/exists, so you can create small sub-regions with different move directions.
As for the camera, give it a z-offset, parent it to an empty GameObject and move that GameObject with the player. You could then rotate this parent object to always have the same y-euler angle as the region the player is in, thereby having it point in the right direction.
Your answer
Follow this Question
Related Questions
2.5D Platformer Camera 1 Answer
Rotate Camera 1 Answer
3d platforming Camera 1 Answer
using left right keys to turn 1 Answer
Rotate camera with player 1 Answer