Im working on a build-engine style unity game, and something regarding my explosion sprites has really been bugging me. My map is split into several pieces for both occlusion culling and my method for dimming certain sections. I want this explosion sprite to only render up until the nearest wall to its left and right, I thought that maybe sprite masks would work but I can't think of any way to implement this in code.
Related
I'm trying to make my character(a box with 2 long boxes as legs) walk using the legs. The point of the game is the challenge of balancing the character and walking with the legs. I've tried using Hinge Joint 2D but I've never used it before so I have no idea of how to use it. I've also seen people use animations but I'm not sure if it would suit my game well because I want the player to be able to rotate each leg 360 degrees so he could find creative ways of walking. Any suggestions?
Joints seem like the best option here. The official unity youtube channel has some good resources for joints: https://www.youtube.com/c/unity/search?query=joint
this is my first answer so please fell free to comment if you have any doubts.
what you and use is making a script to move the leg or in this sense rotate it in one direction. Something like:
GameObject playerLeg;
Input.GetKeyDown("x");
playerLeg.transform.Rotate(10, 0, 0);
if you don't clamp the Leg rotation you should end up with a 360 rotation.
P.S. don't forget to add colliders to the player Body, legs and Floor.
if you want to go a log way with smoother animation and a bit more complex gameplay further in the game you can check out Procedural animation
I'm currently working on a narrative game and don't know how to accomplish something. The game is a 2D platformer so everything is build with sprites. I have a scene with trees and the trees have eyes, I want the eyes to follow the player along, but the "pupils" need to stay within the "holes" of the tree. I have made separate sprites for both the hole in the tree as well as the pupils of the eye's. I would prefer to write it in c# :).
I have also added a concept screenshot, so you can get an impression about what i'm trying to accomplish.
http://imgur.com/pGCV8Uy
Many thanks to the person who can explain to me how to accomplish this!
Well I suppose you could use a joint to restrict the yellow pupils to stay within the holes of the eyes.
Then you could use C# to calculate the relative Vector between the character and the pupil. Guide the pupil to go in the direction of the Vector, and it will be restricted by the joint to stay in the eye. The would result in the pupil always pointing in the direction of the character while staying in the eye, which is what you want.
I am working on a 3D game and it has lots of game objects in a scene. So I'm working on reducing draw calls. I'v used mesh combining on my static game objects. But my player is'n static and I can't use mesh combining on it. My player is nothing but combination of some cubes which uses the standard shader and some different color Materials on different parts. So I'm guessing, I can use texture atlasing on my player to reduce darw calls. But I don't know how to do it.
Is my theory of work right? If I'm right please help me with atlasing, and if I'm wrong please point out my fault.
Thanks in advance.
Put all the required images into the same texture. Create a material from that texture. Apply the same material to all of the cubes making up you character. UV map all cubes to the relevant part of the texture (use UV offset in the Unity editor if the UV blocks are quite simple, otherwise you'll need to move the UV elements in your 3D modelling program).
I'm new to Unity/C# and building a simple game in order to learn it; essentially it involves flying over a terrain and shooting at things.
The question is - How can I create a non-flat, fixed size (ie, not endless) 2D terrain that I can randomise/generate once at the start of a scene.
Here's what I've thought/tried so far:
I started off by creating a massive, flat expanse using a game object with a Sprite Renderer and a Box Collider 2D. I'm using particles for rocket trails and explosions and set them to collide with a plane which worked well. This works, but the terrain is just flat and boring.
Next, I drew some rudimentary mountains in photoshop, added them as sprites with polygon collider 2D components and dragged them onto the scene (with an idea to randomise their locations later). This is quick and works well but doesn't play nice with the particles because of the 2D/3D mix, and I imagine would lead to all levels looking the same unless I can draw a LOT of different terrain sprites. Is this a normal approach? Is it possible to add more planes to the objects to allow particles to collide?
Another thought was - could I create a polygon collider 2D / or edge collider 2D and basically fill the area with a texture? No luck on that one, it seems like it could work but I couldn't get a texture to appear and fit the shape. A shame, especially as I could then generate or randomise the position of the points later.
Finally, I wondered whether I should just use 3D shapes. I can texture them and it works great with the particles, but doesn't interact right now with all my other 2D assets, I'd have to add 3D colliders to them and that doesn't seem right, since Unity specifically provides a 2D toolset and I am trying to make a 2D game.
All of my solutions have pros and cons - maybe there's something I've missed?
You can create meshes procedurally in unity in scripts. They can be either 2d or 3d depending on how you set the vertices. Colliders are independent of the rendered mesh. I dont have an indepth tutorial for this but i think this video will hint you in the right direction and give you keywords to google or read about in the unity documentation:
https://www.youtube.com/watch?v=nPX8dw283X4
I am making an RPG game using an isometric tile engine that I found here:
http://xnaresources.com/default.asp?page=TUTORIALS
However after completing the tutorial I found myself wanting to do some things with the camera that I am not sure how to do.
Firstly I would like to zoom the camera in more so that it is displaying a 1 to 1 pixel ratio.
Secondly, would it be possible to make this game 2.5d in the way that when the camera moves, the sprite trees and things alike, move properly. By this I mean that the bottom of the sprite is planted while the top moves against the background, making a very 3d like experience. This effect can best be seen in games like diablo 2.
Here is the source code off their website:
http://www.xnaresources.com/downloads/tileengineseries9.zip
Any help would be great, Thanks
Games like Diablo or Sims 1, 2, SimCity 1-3, X-Com 1,2 etc. were actually just 2D games. The 2.5D effect requires that tiles further away are exactly the same size as tiles nearby. Your rotation around these games are restricted to 90 degrees.
How they draw is basically painters algorithm. Drawing what is furthest away first and overdrawing things that are nearer. Diablo is actually pretty simple, it didn't introduce layers or height differences as far as I remember. Just a flat map. So you draw the floor tiles first (in this case back to front isn't too necessary since they are all on the same elevation.) Then drawing back to front the walls, characters effects etc.
Everything in these games were rendered to bitmaps and rendered as bitmaps. Even though their source may have been a 3D textured model.
If you want to add perspective or free rotation then you need everything to be a 3D model. Your rendering will be simpler because depth or render order isn't as critical as you would use z-buffering to solve your issues. The only main issue is to properly render transparent bits in the right order or else you may end up with some odd results. However even if your rendering is simpler, your animation or in memory storage is a bit more difficult. You need to animate 3D models instead of just having an array of bitmaps to do the animation. Selection of items on the screen requires a little more work since position and size of the elements are no longer consistent or easily predictable.
So it depends on which features you want that will dictate which sort of solution you can use. Either way has it's plusses and minuses.