Hi, I'm making a 2D platformmer, and I'm going quite well. I've made the general game, I can add boxes, moving platforms, and even enemies. However, I also want to put items into my game.
What I'm attempting to do is create a 2D image that will be displayed where the item is. There will be a light effect just underneath it, and when the character collects it, the item will disappear and he will change colour to what item it is.
Currently, I've only thought of a helium item (because the character is a balloon), where the player will rise up. This can be used to get to higher ledges. However, my first problem is how I can get a 2D image into this 3D world.
Once I know that, I'll put the image and the light into a prefab, and then that'll be one object. Thus, if I use a collider script (which I've used for level changes), then I can try to make the object disappear, and the player will change colour.
However, I'm no good at scripting, so can someone make a script that will activate the helium item?
Since there's many variables, I want the item to disappear when the player touches it, the player to change colour (which I've made another texture), and for the player to rise. Also, if you want, can you explain what each action does?
And lastly, since I'm not great at scripting, I'd like to know a great place I can learn scripting in Unity. The website's scripting tutorial is short and doesn't explain much to me, and I can't seem to make any good scripts while looking through the scripting reference. Any help there?
Thanks for the help. :D
There are a few methods of implementing 2D sprites (so to speak). One involves getting a package (this one I recommend) but it comes with some extra learning required. The other is by using Planes in Unity.
If you don't know in 3D game development, a Plane is a flat surface, upon which you can attach materials just like your default cube etc.
However to get the transparency right on the Alpha sections of the picture you will need to change the material's Shader value (I find Particles -> Alpha Blended works well) without doing this your sprite will be in a white box, and subject to light sources (meaning he'll probably be quite dark looking without a light nearby)
The other method is by getting the SpriteManager, unfortunately SpriteManager 2 has a license fee (large if you're just learning Unity but for a serious Indie developer it's quite affordable).
Happily the first version that was created is available for free, it's is a handful of classes which are on a Wiki page. Simply copy and pasting each into its own script will enable you to use it's features. For a few instructions on how to use SpriteManager you can look at the Wiki page but also 3DBuzz has a video tutorial, setting up some simple demonstrations using it.
As for floating the balloon upwards that depends on how you're moving your balloon at the moment.
If you are simulating physics using a rigid body and forces, then you can just add an upwards velocity upon picking up the power up.
If not you can hard code in the position going upwards for a few frames; depending on how long you want it to levitate you can use a variable as a counter to change the duration and distance, and only apply the change whilst the counter is > 0.
For a more detailed answer I suggest asking this question seaprately. :)
And finally there are plenty of poeple who have asked for tutorials and resources here already, check those questions out. But here are some of the things I used.
Most importantly the Scripting Reference.
Some youtube video tutorials
For help on creating the script, you'll probably want to check out the forums. http://forum.unity3d.com/index.php For the most part, this area is for more specific questions.
As far as the 2D on 3D. I don't know what most newer programmers call that, but back in the day, we called it 'billboarding' (you might need that term to help get your point across). Basically faking a 3D object and having it always facing the camera.
edit::I see sovalopivia got here before me with a lot more info.
answered Jul 30 '10 at 01:38 PM