Hi all I'm trying to make a game where I can drive around and as I pass over certain tiles in my tile-map they change colour, dead simple problem in my head. However not sure how to change the painted tile on overlap, my thinking was I could use sprite collision detection but when I put my sprites on the same z-axis height they overlay and are no longer visible. Is there something I have missed or a more efficient way of going about this?
Thanks :)
Related
I'm beginning with Unity3D and I'm having a problem with the lightning.
I made a simple infinite scroller with a road going straight, and I want to add a pointlight in the middle of my screen, in order to have the road at this place enlightened, whereas the remaining is darker.
However, the light seems to follow the middle of my sprite when this one is moving, instead of remaining static.
Here is a gif of what I have:
My SpriteRenderer has the Sprite/Diffuse material and I added some postprocessing on the camera in order to have a bloom effect on the road.
Do you know what could be the problem here?
Thank you.
Pretty sure you have the Light GameObject as a child of the Sprite, so it follows the parent transform
I took a sprite sheet from the Internet and began slicing it in the Unity sprite editor. It was going well, when I found a sprite that was too close to another sprite to encapsulate the whole sprite without cutting off the top of the one below it! My only non-invasive option was to modify the outline of the shape that you use to cut off individual sprites from a sprite sheet. So how do you make a polygon-shaped sprite slice? picture of my sprite sheet
As far as I am aware, there is no way to change the geometry of a sprite in Unity from a rectangular shape. I am not a rendering expert, but the increase in geometry would add unnecessary overhead to the sprite drawing process.
Your best bet is to edit the sprite sheet in an image editing program such as Photoshop or GIMP, so that all sprites fit into a grid form, or at least a form where they don't violate each other's rectangular bounds.
Try to disable polygon mode. Polygon mode will save space but isn't friendly to rectangle mode.
I am making a 2d game in the perspective of Terraria/Starbound. I want the lighting to look similar to this:
Ive tried to get lighting like this by adding a material on all the sprites in my game and then giving them a sprite diffuse shader. Then I made a point light wherever I needed light. There where two problems with this though: 1) Where the light was most intense, it was draining the color of a sprite and made it lighter. 2) I noticed a big FPS drop (And I only had 1 point light!).
Is there any way of achieving lighting like this without having to write my own lighting engine? Ive search the asset store and Ive searched to see if unity has any way of handing 2D lighting from this angle but I have found nothing.
If I do have to write my own lighting engine, would that be to complex for someone who is relatively new to unity and has only had ~ 8 months experience?
Assume you are using tile map.
You need to have a field of view map, which can be achieved by reading this: http://www.redblobgames.com/articles/visibility/
Using such map, you know exactly the color tinting for each tile. Now, just blend the color to the SpriteRenderer of every tile on the map.
Somebody already created a line of sight plugin:
http://forum.unity3d.com/threads/light-of-sight-2d-dynamic-lighting-open-source.295968/
Here's my hacky solution on GitHub
There's 2 cameras.
Empty tiles on the tilemap are filled in with white blocks (only one camera renders this)
A gaussian blur is applied to the camera rendering the white blocks
Then, blend the two cameras, darkening everything not covered by the white blur.
You can adjust the "light" penetration by changing the white tile's sprite's Pixels Per Unit.
This is just a general question, but is there any way to populate the same sprite in a pattern?
For example, if you drew a shape, a circle, is there anyway you can get the sprites to outline that circle, where they would be slightly spaced apart?
I feel it would be easier to do this than programmatically set the location of each sprite around the circle.
Thank you
I have a ball and another sprite. When the ball collides with the sprite it simulates falling.
My only problem is the other sprite is just on big image and the ball is on top of it, but there are spaces on the sprite and a lot of corners. I need to determine if the sprite has touch one of the corners. I know this is hard to understand.
So, my question is, is it possible to make a body without
b2PolygonShape blockShape;
and
blockShapeDef.shape = &blockShape;
OR
is there an alternative I can use? I cannot set the image as a box and it would take way to long to set edges because there are so many corners.
I have already set up the collision detection.
I really need help with this.
Thanks!
If you want it to react properly, you have to make a polygon using every single corner coordinate.
But don't be lazy about it. You can use SpriteHelper for creating *b2PolygonShape*s out of your sprites.
Or another alternative: VertexHelper