Unity 2D in 3D, by Owlchemy Labs

Views:
 
Category: Education
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

2D in 3D Techniques in Unity:

2D in 3D Techniques in Unity Yilmaz Kiymaz Alex Schwartz

Slide 3:

2D Workflow

2D Workflow:

2D Workflow No built-in 2D Workflow, so let’s create our own. Choose your axes and stick to them! No, not that kind. This kind.

2D Workflow:

2D Workflow Have your planes ready! No, not that kind. This kind.

2D Workflow:

2D Workflow Cameras Orthographic Gives you Easy Positioning Useful for pixel-perfect placement and display Perspective Gives you Easy Parallax

Slide 7:

Our setup

Demo scene setup in ST:

Demo scene setup in ST Show camera looking at menu system Planes, orthographic camera, front to back positioning Menu screens placed side by side Camera moving right gives appearance of elements moving left Unity scene setup Loader scene (company logo) Main menu Game scene Level editor scene

Layering of game level:

Layering of game level Static elements Truck, background, cameras, GameObjects which operate the game Dynamic elements Level Theme Sky / background / cloud materials Ground pieces Obstacles Decoration

Parallaxing (First Camera):

Parallaxing (First Camera) Perspective Camera Distance from camera = slower parallax Illusion of depth Bg, clouds, mesas, deco behind truck, truck, obstacles in front of the truck, HUD

Perspective Issues:

Perspective Issues Perspective Camera = inconsistent sorting DEMO

Sorting Fix!:

Sorting Fix! Render-queue solution (giveaway!) Object can be farther away but still draw in front

Sorting Fix!:

Sorting Fix!

Slide 14:

Creating GUIs

GUI in Unity:

GUI in Unity Two GUI systems in Unity: GUI Elements (old system) Uses GUITexts and GUITextures GUI API calls made in OnGUI() (immediate-mode GUI) Uses GUISkins and GUIStyles, along with screen-space Rects Rolling your own 3D GUI in Unity Use a 2nd camera (orthographic) to render 3D planes as GUI

2D vs 3D GUI:

2D vs 3D GUI 3D GUI - Pros: Scales with resolution Easier to preview in Scene view Easy placement and rotation

2D vs 3D GUI:

2D vs 3D GUI 3D GUI - Cons: GUI functionality built from scratch Buttons, Toggles, Lists Pixel-perfect graphics are hard to get right Text is harder to render nicely, especially on small screen sizes

Resolution independence:

Resolution independence Aspect ratios Most common: 16:9, 16:10, 4:3 Override position of 3D objects depending on current ratio Compensating for small screen sizes Making buttons easy to hit Making it legible Keeping it clean

Slide 19:

Textures

Textures - Issues:

Textures - Issues Most common question about 2d games in a 3d engine “Why does everything look like a blurry piece of shit?”

Texture importing:

Texture importing Mip-maps 1 to 1 textures Always going to appear at the same size on screen = NO MIPS Filtering Bilinear filtering is great for 3d Turn it off for 1 to 1 textures

Textures - Pixel perfect:

Textures - Pixel perfect Single key command Texture dimensions to size your 3d object to exact pixel scale Assuming standard orthographic size Editor Script!

Texture compression:

Texture compression Disk space and memory vs quality PVRTC (iOS) Gradients :-( Few colors :-) Tip: 2x scale + compressed sometimes a good quality middleground DXT (PC/Mac) Not nearly as bad as PVRTC

Textures - Issues:

Textures - Issues How do you handle iPad, iPhone, and PC/Mac resolutions and textures, all in one project without including unnecessary content in each build? “Uh...”

Texture auto-awesome-izer:

Texture auto-awesome-izer Maintain 4 builds iPhone, iPad, Webplayer, Standalone (PC/Mac) Multiple aspect ratios Some textures are unique to one platform NO PROBLEM!

Texture auto-awesome-izer PART 1:

Texture auto-awesome-izer PART 1 BuildSettings.xml Define compression, auto-scale-downs, mips

Texture auto-awesome-izer PART 2:

Texture auto-awesome-izer PART 2 PlatformSpecifics Class Define custom positioning, scale, texture swaps, font changes, text swaps

Texture auto-awesome-izer PART 3:

Texture auto-awesome-izer PART 3 DEMO! Showing platform specifics used in main menu

Slide 29:

Gameplay and Physics

Physics:

Physics Unity uses a 3D Physics engine - PhysX Wasted performance? Not enough to care about. Pretend the objects are 3D Constraining movement of physics objects In some cases, we don’t want “into the scene” movement Constraining rotation

Physics:

Physics Joints More recently, Constraints in Rigidbody Gameplay implications of a 3D physics interaction In Smuggle Truck Room in cargo Passenger interaction Make room for the babies

authorStream Live Help