# 2D Camera Rotation Along Level Boundaries

 0 I'm very unfamiliar with scripting and I started learning Unity a month and a half ago. I'm working on a 2D platformer for my class and I'd love to change my camera angle from a straight side view to a slightly downward looking angle (positive rotation along the Z axis). My class has been using a lot of standard assets and prefab scripts, and for this project we've been using a slightly customized Lerpz platformer demo. I have level boundaries collider that my camera is fixed upon, moving in only the X and Y axes. Since my boundaries inform my camera movement I assume that the most straightforward way to create rotation is to input transform.rotate in the boundaries script. Is this a correct assumption, or is there a better way? And if I should transform.rotate, how would I format it within the code? Would I create a variable function or combine it with `function Start`? Here's the complete LevelAttributes/Boundary script: ``````// Size of the level var bounds : Rect; var fallOutBuffer = 5.0; var colliderThickness = 10.0; // Sea Green For the Win! private var sceneViewDisplayColor = Color (0.20, 0.74, 0.27, 0.50); static private var instance : LevelAttributes; static function GetInstance() { if (!instance) { instance = FindObjectOfType(LevelAttributes); if (!instance) Debug.LogError("There needs to be one active LevelAttributes script on a GameObject in your scene."); } return instance; } function OnDisable () { instance = null; } function OnDrawGizmos () { Gizmos.color = sceneViewDisplayColor; var lowerLeft = Vector3 (bounds.xMin, bounds.yMax, 0); var upperLeft = Vector3 (bounds.xMin, bounds.yMin, 0); var lowerRight = Vector3 (bounds.xMax, bounds.yMax, 0); var upperRight = Vector3 (bounds.xMax, bounds.yMin, 0); Gizmos.DrawLine (lowerLeft, upperLeft); Gizmos.DrawLine (upperLeft, upperRight); Gizmos.DrawLine (upperRight, lowerRight); Gizmos.DrawLine (lowerRight, lowerLeft); } function Start () { createdBoundaries = new GameObject ("Created Boundaries"); createdBoundaries.transform.parent = transform; leftBoundary = new GameObject ("Left Boundary"); leftBoundary.transform.parent = createdBoundaries.transform; boxCollider = leftBoundary.AddComponent (BoxCollider); boxCollider.size = Vector3 (colliderThickness, bounds.height + colliderThickness * 2.0 + fallOutBuffer, colliderThickness); boxCollider.center = Vector3 (bounds.xMin - colliderThickness * 0.5, bounds.y + bounds.height * 0.5 - fallOutBuffer * 0.5, 0.0); rightBoundary = new GameObject ("Right Boundary"); rightBoundary.transform.parent = createdBoundaries.transform; boxCollider = rightBoundary.AddComponent (BoxCollider); boxCollider.size = Vector3 (colliderThickness, bounds.height + colliderThickness * 2.0 + fallOutBuffer, colliderThickness); boxCollider.center = Vector3 (bounds.xMax + colliderThickness * 0.5, bounds.y + bounds.height * 0.5 - fallOutBuffer * 0.5, 0.0); topBoundary = new GameObject ("Top Boundary"); topBoundary.transform.parent = createdBoundaries.transform; boxCollider = topBoundary.AddComponent (BoxCollider); boxCollider.size = Vector3 (bounds.width + colliderThickness * 2.0, colliderThickness, colliderThickness); boxCollider.center = Vector3 (bounds.x + bounds.width * 0.5, bounds.yMax + colliderThickness * 0.5, 0.0); bottomBoundary = new GameObject ("Bottom Boundary (Including Fallout Buffer)"); bottomBoundary.transform.parent = createdBoundaries.transform; boxCollider = bottomBoundary.AddComponent (BoxCollider); boxCollider.size = Vector3 (bounds.width + colliderThickness * 2.0, colliderThickness, colliderThickness); boxCollider.center = Vector3 (bounds.x + bounds.width * 0.5, bounds.yMin - colliderThickness * 0.5 - fallOutBuffer, 0.0); } `````` more ▼ asked Apr 07 '12 at 06:06 PM messierstudios 0 ● 1 ● 1 ● 1 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 You don't need all this - waste of time.Use and orthographic camera instead of perspective. It makes the objects that are still 3 Dimensional have no depth at all. Also the downward you're talking about - Change the Y Rotation to 70-90. Felipe more ▼ answered Apr 07 '12 at 06:39 PM BigBlob 340 ● 37 ● 62 ● 66 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x5086
x3009
x2168
x1281
x13

asked: Apr 07 '12 at 06:06 PM

Seen: 582 times

Last Updated: Apr 07 '12 at 06:40 PM