With the Unity 3.5 developer preview being made available to the public yesterday, I set out to try the new Unity to Flash exporter. I’ve been looking forward to this feature since it was announced almost a year ago. The first project I decided to work on was Office Zombie Simulator, a small game Calin and I build back in February.
The major stumbling block with porting this project to Flash was that it uses iTween. As a lot of people have discovered iTween does not work with the Unity Flash exporter. Yesterday, I spent the day hacking iTween and got it to work with the Flash exporter. Get the modified version of iTween here.
With iTween working, I spent part of the day fixing up a few issues and now Office Zombie Simulator works in Flash. While it’s a little rough around the edges it is simply amazing that I’ve brought something of this complexity from Unity into Flash in just a couple of days.
To me the most exciting thing in the developer preview is the Unity to Flash exporter. The ability to easily create and distribute 3D content on the web without needing the user to have a different plugin.
So the first thing I did was start to port over some older projects. As this is an early build there are a lot of limitations, so moving an existing complex project over isn’t an easy task. One of the major stumbling blocks I had (and from the sounds of things a lot of people are having) is that iTween simply doesn’t work.
iTween is great framework for doing tweening in Unity. So I decided that with my deep knowledge of Unity, iTween and AS3 I would attempt to ‘fix’ the iTween libary to work with the Flash exporter.
Turns out iTween uses a lot of unsupported features and that coupled with the exporter being very new, turned this into a very challenging problem.
45+ hacks and a lot of knowledge later, I won.
Without further ado here is Flash export ready version of iTween:iTween.cs
This version of iTween is a little rough around the edges, but it works in my initial tests.
Known Issues
-ColorTo & ColorFrom are unsupported as they cause an infinite loop (reason unknown)
-FadeTo & FadeFrom are unsupported as they cause an infinite loop (reason unknown)
-Flash player throws a silent error on Destroy of iTween component (should not effect anything but will show up in Flash debug)
There are probably more issues so let me if you come across any.
I do know that a new version of iTween is being worked on and the Flash exporter is in an early state so this is a temporary version to hold everyone over.
PS: This took me an entire day, so if someone uses this to win the Unity ‘Flash in a Flash’ contest you official owe me a drink.
The other day I discovered a sweet feature in Unity that has existed for a long time. With this I decided to create a short list of some cool features in the Unity editor that you might not be aware of.
2) Multiple Inspectors – Click the ‘context menu’ icon (next to the ‘lock’ icon) in the inspector. In that drop down, select ‘Add Tab’, then ‘Inspector’. Use in conjunction with inspector lock to become a productivity machine.
(via @AngryAnt – http://twitter.com/#!/AngryAnt/statuses/142724785384865793)
3) Project and Hierarchy Search By Type – Not only can you search for items by name, but also by type. To do this, click the ‘Search’ icon drop down and select ‘Type’. Or to be more efficent, simply type ‘t:type’. Ex: t:texture, t:material, etc.
(via @aras_p – http://twitter.com/#!/aras_p/status/143010880706183168)
4) Inserting and Deleting Items From Arrays In Inspector – Populating arrays using the Unity editor is very handy, that is until you realize that you need to remove or add an item in the middle of the array. It might appear that there is no way to do this, but there is. To duplicate an item, select it and hit Ctrl-D (Windows), Command-D (Mac). To delete an item, hit Shift-Delete twice (once to clear, second time to remove it)
7) Editing Primitive Collider Dimensions in Scene View – Select a GameObject with a collider and hold down the shift key. Small greens squares will appear in the Scene View which you can then manipulate. http://unity3d.com/unity/whats-new/unity-3.4.html
8) Adding Game & Scene View Icons to GameObjects – Click on the GameObjects icon in the inspector. From this drop down you can select the icon type, color and even create a custom icon. You can also add icons to custom scripts. Select the script in the Project panel. Then click it’s icon in the inspector. This icon will get applied to all GameObjects that have this script attached. This is very handy for marking things like waypoints. http://unity3d.com/support/documentation/Manual/Gizmo%20and%20Icon%20Visibility.html
9) Snap To Vertex or Collider – To snap to vertex, hold ‘V’ and then click and hold down on the desired vertex. Drag your mouse around to snap it to the required vertex of another mesh. To snap to collider, hold Shift while dragging in the center when using the Translate tool. http://unity3d.com/support/documentation/Manual/Positioning%20GameObjects.html
10) Scripting the Editor – This is one of my favourite features and something people do not do enough of. If there is something the Unity editor doesn’t do by default you can write it yourself. Extending the editor is very easy and incredibly powerful. As an example I wrote a tool called PlayModePersist that can save changes your made in the editor while in PlayMode. http://unity3d.com/support/documentation/Components/gui-ExtendingEditor.html
If you have any additional items you would add please put them in the comments below.
The concept, create an interactive 3D scene by augmenting video not shot from a fixed point. The idea came from old arcade on-rails shooters. I wanted to know if you could shoot a video of an environment for an on-rails shooter and then add interactive 3D models at run-time in such a way that everything seamlessly fit together. I’ve seen this attempted in the past, but the camera would always have to stop moving when the scene became interactive. On the other end is Augmented Reality, where generally it is real-time video with a fixed point.
With the help of Calin Reimer(modeling & art) and Kert Gartner(video and camera tracking) we managed to build a working tech demo this last weekend at PegJam.
Now onto the cool part, how did we achieve this.
First we found a suitable area to shoot the video (interesting but not too cluttered). We then shot a short video moving the camera around the environment.
This video was then brought into a piece of camera tracking software where the scene was tracked. This then gave us the position and path of the camera during the whole video. This was exported as an FBX file and the video was converted to an image sequence.
A rough 3d model of the scene including all objects in the environment was created.
The image sequence, camera track and 3D scene model where then all brought into Unity.
Within Unity a static orthographic camera was setup to view a plane scaled to the video’s dimensions. The current time was used to determine the current video frame and this video image would be added to the plane. This creates a video player that while a little slow, has the required control needed for the project. As a note we did attempt to use Unity’s built-in MovieTexture but it was just not robust enough for this project.
Next a new camera was added into the main camera tracking node. This allows that camera to follow the exact same path the real camera did when we shot the scene. The camera’s “Field Of View” was also modified to closely match that of the actual camera.
The camera tracking animation could not just be played like a normal animation. The problem was this would move the camera into between video frames causing alignment issues. Instead the camera’s animation was manually played based on the current frame of the video.
The 3D model of the scene was position within the camera track. Box Colliders were added and a custom shader that occludes all objects behind it was applied. Lights were placed in the scene to roughly match the actual lighting in the environment.
Lastly we added the remaining items like the gun, laser, laser mark decals and enemies.
We render the camera that captures the video first, followed by the 3D scene camera and lastly the camera that renders the gun.
When it is all played together it works to give you the illusion that everything actually exists in that scene.
I’ve very excited of what we were able to accomplish in one weekend. If you are interested you can download the project source below. A quick word of warning as we built everything in one weekend this project is a bit crazy.
Thanks to some great feedback from users I’ve added a bunch of new features and a few fixes.
What is new in Version 1.5
Shortcut key : Open/closing the PlayModePersist dropdown : Shift+Alt+O
Shortcut key : Persisting all components within selected GameObject : Shift+Alt+P
Auto Persist Settings - Ability to search for and add components you would like to always auto persist in all your projects (Window -> PlayModePerist Auto Persist Settings)
Bug Fix : Issue persisting multiple GameObjects at the same time
Bug Fixes : Cleaning up warning and error messages that can occur since Unity 3.2
These new features make PlayModePersist not only easier to use, but should save you a lot more time.
While it is still a work-in-progress I am very happy with how it turned out considering how swamped I was this last month (So Many Rooms and client work).
When I heard the announcement for Kongregate’s Unity Game Contest I was very excited and knew I needed to create something for it. I love game development contests because they have a great feature; a fixed deadline.
The premise of “Office Zombie Simulator” is pretty simple, imagine a few zombie loving nerds are stuck in an office for the weekend. Instead of working they decide to setup the ultimate zombie apocalypse simulator.
The idea for “Office Zombie Simulator” came to me out of necessity.
One problem that we keep running into with developing 3D content is the amount of time and effort required to build all the necessary 3D models. So the idea was if we could reuse more models between projects we would save development time. Since another project we were working on required office equipment I thought if this game could be set in an office, we could hit two birds with one stone.
Other than that the game shouldn’t have any complex 3D models or animations (too time consuming) and needed to be easy to pick up and play.
After a few days of brainstorming, the concept for “Office Zombie Simulator” was born. It turned out to be a very cool concept and is more proof that creativity works best under constraints.
We are hoping enough people will enjoy the game to warrant us building a fully realized version. We have a lot of cool ideas that we would love to implement.