I was left with a pile of assets from a video game project that went under last year. I need to bring this project together into at least a demo. Instead of dumping all of my problems on you all at once, I am going take this one very small step at a time.
The first hurdle that I tripped and fell over was trying to get high res 2d images into unity to use for a 2d level design. What I need to do is place these images in Unity’s 3d space and add some sort of working collider that will allow a character to ‘walk’ ontop of and collide into these images(platforms).
If anyone could point me in the right direction for getting this completed, I would be eternally grateful.
Here is an image of a level that I am working with. (It is a .psd file with everything split into different layers)
EDIT:
I forgot to mention some potentially important pieces of info.
This game is going to released on iPhone and Android.
I have access to UnityPro w/ iOS and Android.
I have access to the plugins SpriteManager 2 and EZGUI
Just use an orthographic camera.
Put the 2D background on a plane at the back of the scene.
Place invisible cubes at the various platforms in the image.
Download the platformer tutorial from the unity resources page and grab the player prefab.
Have the camera follow the player as they jump around so that the camera pans across the background as you move.
I dont know about proper 2d collision, but i know that it could always work with 3d collision. So all you do is just create 3d colliders from cube and place them on top of images, or use custom meshes for colliders to fit better on top of images. Then you also place one box collider on your character and its done. It isnt the fanciest way but it will defenetly work.
Would like to start by saying I don’t have experience with 2d games but I do use EZGUI. My advice would be first to start explaining the problem?
If you do have a character, I’m guessing that what you just said about placing on the Z axis your sprites with colliders should work… or do you want more generic advice from people who did implement such levels? In that case, maybe the support forums for SM2 would contain more expertise as a lot of 2d-game veterans hang in there =)
Is there a way to ‘trace’ the outline of a 2d image to create a mesh that could then be ‘extruded’ into the third dimension so it could be used as a collider in unity.
Most 2d games are either tile based and implement their own collision system or use box colliders. Just look at Braid. Fantastic, organic graphics, but it used box colliders for collision.
I will keep the box colliders option open, but I would prefer to use a traced mesh as the collider instead of just boxes.
Expanding on my questions… what would be the best way to place the individual ‘platforms’ of the level into unity’s 3d space. Each block/platform is in psd format. I know that the atlas limit for mobile devices is 1024px and some of these blocks go up to 5000px wide. Will i have to tile these images to make them fit within the atlas limit without losing quality, and if so what would be the best way to do this.
Hi Ray, it’s Aaron. Sorry I took so long to respond.
Just to provide a bit more explanation for the work Ray is doing. We are converting a game from XNA to Unity. The XNA game used the Farseer Physics Engine which has a “Texture to polygon” tool that will generate polys for a mesh collider.
@Ray: I think the best route right now would be to write a small C# app that gives us access to the Farseer API. We’ll just load the PNG files into the app, let Farseer process them, and then spit the poly data back out as XML files.
Then I will just build an importer that loads the XML files and generates a mesh node that you can use to build a mesh collider.
That is unless anyone knows of a feature or a plugin for Unity that already does something like this.
I wrote the basics of an application that uses XNA and the built in Farseer functions to generate Polygons from PNG files. It’s still got a way to go, here’s some initial XML code generated by app.
The XML file can be found here.
The PNG it was generated from can be found here.