Hot answers tagged

5

One approach is to simulate natural growth of a real village. Looks good and organic. May be iterated to expand forever. Easily adopts to existing terrain (rivers, forests, cliffs). Start with a house in the middle of the area. These are your first settlers. Choose a building type that is most needed next, considering what was built already and what is yet ...


4

Rule based placement This approach will probably need revising once you start having more different building types and rules to their placement, but the task is assumed to be exactly as specified and should be able to expand somewhat as needed: List of fixed building types as input. Each building type comes with a set of rules for placement. Buildings are ...


2

Make sure that: You have a Collider2D(BoxCollider2D etc.) added. Physics2DRaycaster added to your camera. EventSystem in your scene. Nothing is blocking the Raycast to this SpriteRenderer. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; [RequireComponent(typeof(Collider2D))] public class ...


2

It could be that you are trying to push the image smaller than the original. Zone D, E and F are used for resizing the image, but if you push it smaller than your buffer zones can provide, it has to resize the corners. Your image looks like 512px height in the original and you try to display it at a new height of 100px


2

When coding in assembly, it can be easy to mix up your data format. In this particular case, the assembly code is expecting the .pal and .vra files to be in hex / binary. For instance, here's the .pal data from the tutorial: The far left columns indicate the memory offset, the middle column is the data in hexadecimal form & the far right column is the ...


2

So I figured out a solution. I basically check the previous direction I got from my function (without rounding it) and check the angle with the new direction my sprite wants to go (without rounding it) by doing Vector3.Angle(previousVector,direction) and then verify if the angle is greater than 30. If it is, I change the direction. If not, I keep the ...


1

You can do this with the rather new 2d animation package. It allows you to create a skeleton for a sprite and animate that skeleton. Although that usually doesn't work too well with low-resolution pixel-art. It works better with large, painted sprites. It also doesn't work very well with turning a sprite around the y-axis, so if you need sprites facing ...


1

With the following assumptions: You have a maximum number of building of each kind to place. You have adjacency rules (such as: House can be adjacent to House, Church and Factory; Church can be adjacent to House; and Factory can be adjacent to House and Factory). You can do this (explanations in comments, ugly details to make it work in JavaScript at the ...


1

Your solution might work with a world-space canvas, but I don't recommend using world-space canvases for most situations because it's difficult to make them adapt to different screen aspect ratios/resolutions. If you're using a Screen Space canvas, you need to convert the world coordinates of the sprite renderers into screen space, then convert that into ...


1

A negative scale can adversely affect physics features. When you flip a shape backwards, collision/raycast checks that depend on the winding of the collider effectively see it as inside-out. So you might find the object becomes invisible to collisions/clicks when inverted. Changing the scale might also force the physics engine to recompute the object's ...


1

The issue most likely has to do with the skin & bone animation. The polygon collider will not update itself every frame while the sprite is animating. Your best option would be to use a simple collider instead, but if you really need it to be very accurate, you'll need the colliders to be placed on the objects and updated as they rotate/move around.


1

For those of you following or facing a similar problem, I believe I found a relatively easy solution. Considering that I'm travelling around 360 degrees to make a shape, I can use the angle to calculate the particular shading at that point (based on the direction). The same logic is commonly used to apply normal maps While they don't look perfect, the code ...


1

Shading is about indicating the 3D shape of the object, so to shade an object well you have to generate its 3D shape. On your first pass, instead of making a flat colored shape, you could make a heightmap, then in your shading pass you can color and shade the heightmap based on adjacent pixels.


1

I would look into using a plane instead of a sprite for something like this and changing it's texture to be your image. Planes will not draw their backface. Sprites aren't really intended to be used in 3d in this way.


1

You can use Leshy's tools to split non uniform spritesheets: https://www.leshylabs.com/apps/sstool/ Your spritesheet is 32x32. I've used it before:


1

I had a similar issue before. It seemed to be related to the mask custom range. For example if my target order in layer is 99, then I have to set the range as [98,100]alt text If I set the range as [98,99], the editor works fine, but the build shows no effect. Here's a link to the Unity forum post where I posted this in reply to a similar problem.


1

I'm kinda late, but I was having the same problem, so yesterday I made a tool that tries to handle the case of the accepted answer (it identifies each rectangle in each animation line, then sorts then by line, so you can use the output to create a list of rectangles for each frame of each animation in each sprite sheet, instead of marking the rectangles ...


1

You haven't given a lot of information here. What components are attached to the block prefab (SpriteRenderer? Image?)? My best guess is that you're looking at imprecise pixel alignment, which can happen when the edges of objects in Unity space are not precisely aligned with pixels on the screen. If these objects are Images displayed in a canvas, you can try ...


1

Well I got a few tips for you to try to get it working : I'm not really sure what the exact issue is. I think it might might actually be a bug in Unity. Anyways, it deals with the SpriteRenderer and the order in which it is applied to the gameobject (relative to the Particle System).Try to remove the SpriteRenderer, and then add it (or just create a whole ...


1

Click on the image asset in your "Project" tab and check its import settings in the "Inspector" tab. For pixel art you usually want the following settings: Texture Type: Sprite (2D and UI) Filter Mode: Point Compression: None


1

Click on your texture, the texture import settings appear in the inspector window.... look for Filter Mode... bilinear, trilinear, point. Try changing it to Point(no filter) and that should eliminate any distortion. And what do you exactly mean by distortion? It seemed fine for me when I imported with point filter mode. Anyway let me know if it worked.


1

Thanks to DM Gregory's comment, I have understood and solved the issue. Since I am using the Head object in animator, the sprite is updated in every frame. Therefore, even I change it in one frame, it goes back to default in the next one. This is the right way to do it: public class PlayerHead : MonoBehaviour { public static PlayerHead instance; ...


1

The cause Now you have selected that walk in some direction can be triggered from Any State. Thus, if you have vertical = 1 and horizontal = 1 in WalkingNorth state, your transition to WalkingEast is triggered (it meets the condition for horizontal = 1) and vice versa (transition to WalkingNorth is triggered when in WalkingEast state because of vertical = 1)....


1

This happens when the GameObject is very far away from the world center. Check its transform in the Inspector. The x, y, or z coordinate is probably greater than 100,000 units. You should never position anything this far from the world origin unless you have a good reason to.


Only top voted, non community-wiki answers of a minimum length are eligible