I want to create a 2d game with tiles that are interactable, i.e farmland, trees, breakable rocks, etc.
Now if I create my tilemap in Tiled which I have done so far, it does not offer that type of control.
I found some posts on how to deal with this but they are at least 3 years old, so wondering if there is some updated answer? maybe something built in to Unity or a plugin I'm not aware of to help create Tilemaps inside Unity?
I want, for example, 1 tile of grass to be able to react if I hit it with a hoe, or water, and change to dirt. Is my only option to create prefabs and place every tile as its own gameobject? won't that kill performance in a large world?
You could try exporting your Tiled tilemap to .tmx format, creating a script in Unity that loads .tmx files for your map and reads every single tile in a for loop.
You would need to assign a prefab to each tile ID of your tilemap, and in that prefab you could have your script with logic attached (grass reacting to a hoe/water) and graphics.
Other idea is to export one big image of your map, and then export .tmx format in the same way as explained before but create game objects only for ID's that player can interact with and only attach scripts to them.
Related
Whats going on is, I want to detect what the tile I'm clicking on is, but I'm unsure of how I can do that if my tilemap consists of multiple layers. For example, with the way my script is currently set up, the ground level 'island' can be passed into the script as the 'map' variable, but then I wont be able to see if I am clicking on the house, which is in a separate layer. I'm new to Unity so I apologize if I'm explaining it badly, but basically I need a way to look through multiple layers of the tilemap to see what is being clicked on. In the future I would want to implement some sort of system in which a tile could have some sort of modifier sprite on top of it in a higher layer, so I would want to see the tiles in both layers, another reason I'm wondering if there's a way to cycle through those tiles.
I'm working on a little game where tilemap gets generated.
This is so far not done in chunks and pretty basic.
Single tiles (rule tiles) of the tilemap can be destroyed by the player.
This is working so far (and took me long enough to figure out!)
Now I am looking for a way of saving tilemap data that allows me to give each tile a specific amount of lifepoints (so that the player needs to hit harder tiles twice oder three times before they get destroyed.
Also upon destruction I want the tiles to be able to drop loot (like gems).
How would you go about this?
I thought about putting gems etc. on a different (visible) tilemap and while destroying the tile of the "ground" tilemap check if for the same position of "gem" tilemap there is an object. If so destroy it and drop item to be picked up by the player.
I'm quite lost on this one, so every input is very welcome!
Thanks.
I want to create a game with a maze(not really) in it. The whole map should be surrounded by wall and inside these walls there should be a maze. This maze should be randomly created. On every tile where no wall is placed, the player should be randomly placed. Is there a build in class/function in SpriteKit that can fulfill my requirements or do I need to come up with an algorithm by myself?
PS: A possible visualization would be the game PacMan with randomly created stages.
You can use a tile map to create your maze/levels, but you will need to write the code to do this. It will be a tough algorithm to ensure that each level is playable/winnable. Might be worth starting with defined layouts to get the game play right, then add in random generation.
I'm experimenting with an AR experience in Unity3D. I'd like to place models in my Unity scene and have them show up on top of real world objects using tango. I'm using tango's augmentedReality scene as a starting point.
Say there is a table in a room and I want a 3d cube to sit on top of it when it is in tangos view. Do I need to be using an .adf file to solve this problem or is there something else I should be looking into.
Is there some way to test an .adf file locally in my unity scene? This would be ideal to establish and debug the correct positions to place models in my scene.
Just trying to sort everything out.
If you want keep your virtual object's position persistent between different runs of the application, you will need a ADF file to relocalize. Unfortunately, there's no in-editor debug functions for ADF at the moment, so you will need to create a program to place the objects.
You could take a look of the Experiments/PersistentState example for reference. This example is not using AR, however, it's saving objects position with respect to your ADF's origin and keeping them persistently.
I'm starting to use Maya to do some bone animations of a 2D character, which is composed of several different parts (legs, body, head, weapon, etc.). I have each part in a separate .PNG image file. Right now I have a polygon for each part, with its own material and texture:
I was wondering if there's a way to automatically combine the textures into an atlas, make all the polygons use the same material with the atlas, and correct their UV maps so they still point to the right part of the atlas. Right now, I can do it manually in reverse: I can make the atlas outside Maya with other tools, then use the atlas on a material and manually correct the UV maps of each polygon. But it's a very long process and if I need to change a texture, I have to do it all over again. So I was wondering if there's a way to automate it.
The reason why I'm trying to do this is to save draw calls in Unity. From what I understand, Unity can batch objects as long as they share the same material. So instead of having a draw call for each polygon in the character, I'd like to have a single draw call for the whole character. I'm pretty new to Maya, so any help would be greatly appreciated!
If you want to do the atlassing in Maya, you can do it by duplicating your mesh and using the Transfer Maps tool to bake all of the different meshes onto the duplicate as a single model. The steps would be:
1) Duplicate the mesh
2) Use UV layout to make sure that the duplicated mesh has no overlapping UVs (or only has them where appropriate, like mirrored pieces.
3) Use the Transfer Maps... tool to project the original mesh onto the new one, using the "Use topology" option to ensure that the projection is clean.
The end result should be that the new model has the same geometry and appearance as the original, but with all of it's textures combined onto a single sheet attached to a single material.
The limitation of this method is that some kinds of mesh (particularly meshes that self-intersect) may not project properly, leaving you to manually touch up the atlassed texture. As with any atlassing solution you will probably see some softening in the textures, since the atlas texture is not a pixel for pixel copy but rather a a projection, and thus a resampling.
You may find it more flexible to reprocess the character in Unity with a script or assetPostprocessor. Unity has a native texture atlassing function, documented here. Unity comes with a script for combining static meshes, but you'd need to implement your own; theres'a an example on the unity wiki that probably does what you want : http://wiki.unity3d.com/index.php?title=SkinnedMeshCombiner (Caveat: we do something similar to this at work, but I can't share it; I have not used the one in this link). FWIW Unity's native atlassing works only in rectangles, so it's not as memory efficient as something you could do for yourself.