Hot answers tagged

50

Large, open areas do not work very well in top-down 2d. Putting the player in such an area just disorients them. It is much better to use more complex areas which limit the way the player can navigate. So you need some other way to communicate the scale of the world to the player. A common way to do that is by providing them with a world map they can access ...


28

This is Matt, the creator of Trainyard. @DMGregory summoned me here! :) It sounds like you're working through the same issues I had to deal with. It's a tricky problem where there isn't necessarily a perfect solution. One thing to consider is the constraints of the problem. I was targeting a 50mm wide screen on the early iPhones, and Apple's recommendation ...


19

I believe the answer lies in 2.5D If your game is a 2D sidescroller, then you may rely on parallax scrolling, shadows and lighting to convey size and scale better. If your game is a 2D topdown or isometic, your scale will benefit from assets that get drawn above the player (such as trees that extend above their own tile). Once again, shadows and lighting ...


10

Conveying scale accurately can be tricky in 2D games. There are other ways of conveying that "go this way to reach this objective" feeling, but you have to think about it within the medium itself, instead of trying to translate 3D methods into a 2D world. A 2D view gives you a better awareness of all nearby objects than a 3D one - you don't need a mountain ...


7

You can't give ambient occlusion to things when there is no light. After all ambient occlusion effectively simulates shadows. Add more light sources (and use shadows) If you add light sources to the game (lava, camp fires, mining lights, glowing mushrooms, etc.) you can go in and start giving things shadows which will make it seem more 3D and add details. ...


7

In addition to all the great answers, here's another part in the mix that can expand the perceived scale -- content clues: A horse cart is racing by, apparently towards some grand destination A signpost points to "Castle 5 miles this way" A "Traveler's Inn" by the road has people resting from the "long road from and to Landmark" A flock of birds travel by, ...


6

I think you can solve the two pain points you indicated with a few heuristics. One is a little hysteresis: once the player is drawing in a particular row/column, keep their drawing cursor locked in that row/column until their mouse/touch point strays more than ~30% of the way into the next row/column. That gives more tolerance for error, so the player has ...


5

Consider using 3/4 top-down perspective. This is the look that most old-school top-down games used specifically to create depth. Some examples: Old Zelda games Old Final Fantasy Games Pokémon (even once they transitioned from pure pixel art) Binding of Isaac (Rebirth) is a good non-RPG example, it involves a lot of shooting: (the room walls aren't ...


5

How do you approach Canvases in Unity? It's possible to use more than one screen-space canvas in Unity, but it's uncommon. There is usually no reason to do that, unless you want different UI elements to use different basic canvas settings. If you want your game to support multiple resolutions, then you want to avoid absolute positioning. You usually anchor ...


4

Your problem lies in generating the graph, before any actual pathfinding takes place. It looks like you want the intersections of tiles to be considered the nodes of your graph, and only want intersections where all four adjacent tiles are ground. If you do it correctly, the pathfinder in your example will have only one valid path to choose from.


4

You would usually use the canvas for UI elements. You can anchor your elements relative to positions and it should take care of your scaling for different dimensions if done correctly. A gameobject and prefab are almost the same. A gameobject basically is a container of something. It can hold multiple scripts, your sprites, colliders, etc. Take a look at ...


4

Physics Try to think about what happens when a cannon ball traveling through the air hits something. The ball will have a certain mass and velocity, and thus a certain amount of kinetic energy that can potentially do damage. What happens with the cannon ball itself after a collision? Does it bounce, fall down, break apart, roll, catch fire or explode? It ...


3

No, it can't. Unity won't allow you to add both a Rigidbody and a Rigidbody2D to the same game object: It also won't allow you to add both a 3d Collider and a 2d Collider: What you can have, though, is objects with 3d colliders and other objects with 2d colliders in the same scene. But those objects won't interact with each other in any way. They will ...


3

Why have we arrived at the convention that rotations should be counter-clockwise then, even in engines where positive y is down? Have we? Let us try CSS: const box = document.getElementById("box"); function step(timestamp) { let deg = timestamp/10; box.style.transform = "rotate(" + deg + "deg)"; window.requestAnimationFrame(step); } ...


3

You should not multiply by delta time here: float newRotation = verticalMovement * m_AimAmount * m_DeltaTime; Multiplication by delta time is useful when you're accumulating an incremental movement each frame, so the total movement builds at a consistent rate even if your frames are uneven durations. But that's not what you're doing here. Here, every ...


3

Just download this script AnimatedTile and put it into your project, then you can find AnimatedTile at Create > Tiles > Animated Tile. In case you don't want to click the link, I copy the script for you using System; #if UNITY_EDITOR using UnityEditor; #endif namespace UnityEngine.Tilemaps { /// <summary> /// Animated Tiles are tiles which ...


3

This problem is just begging for Newton approximation like recursions. How to find distance of arc up to precision required? First iteration: Find out the distance between both endpoints. Create new points at 1/4 of a distance from 1/4 first control point to 3/4 of second control point, plus 3/4 of a distance from 1st point, plus 1/2 the distance. Measure ...


3

One way of conveying distance in any game is to make it take a long time to get from one place to the other. One of the largest game worlds in my memory is a MUD I used to play that artificially separated provinces by sea voyages that took anywhere from a few minutes to a few hours. Within each province, it was fairly quick to walk from one place to another,...


3

You have at least one obvious error at hand. foreach (RectangleShape obstacles in JumpAtObjectList) { MainPlayer.Jump(deltaTime, obstacles); break; } break tells the foreach loop to exit and since there is no condition, it will always exactly run one time for the first obstacles in JumpAtObjectList. What you probably wanted is to check if the ...


3

You can do this more simply by having one coroutine that expresses the sequence of actions you want to perform: IEnumerator MovePauseAndReturn() { yield return MoveTo(targetPos); yield return new WaitForSeconds(1); yield return MoveTo(origPos); } And a workhorse that performs the move: IEnumerator MoveTo(Transform destination) { while (...


3

If I understand correctly, you want the algorithm to return a path that touches the center of each grid (the red dots, in your last image) rather than one that goes along the grid lines (the blue line, in your last image). To accomplish this, you need only to add the half-size of your node to the node's world position. For example: Given a node whose grid ...


3

An EdgeCollider2D would handle this case well. Much like a LineRenderer, you provide it a list of points to join into line segments, marking your collision boundary. It can be a closed shape, but it is not required to be closed.


3

Set the pickup to be on a layer that interacts with the ground only, not the player character. Give your player character a child object that represents their collection radius. Give it a trigger collider, and set just this child object to be on a layer that interacts with the pickups, leaving the root of your player character on its original layer. Now your ...


2

I will describe an approach I used for a similar game some time ago. Depth imitation This only applies if your perspective is not orthogonal and directly from the top. For each sprite that has depth I have the normal color bitmap and a height bitmap. So for example the wall sprite could look like this Heightmaps use only the r component. Each sprite is ...


2

DDS support is standard in GIMP since version 2.10, plugin installation is no longer required.


2

Fast travel is often used to convey scale, in both 2D and 3D games. As this answer mentions, time is an effective substitute for scale, but with a graphical game you do not want artificial delays, so make the delays the real effect of having a large world. Most games will have a smaller "intro" area, and if this area is large enough it can take some time to ...


2

I would assume you actually want to use the Physics2D.OverlapArea function instead. It takes in two Vector2's which are the top left corner and bottom right corner of a rectangle. The result is a Collider2D that the function found was overlapping the input rectangle. So your function would be: private void RandomOBS() { Vector2 pos = new Vector2(...


2

Don't scale your jump velocity by Time.deltaTime What that says is "If I running at a low framerate, jump higher" which is not what you want. You want a consistent change in velocity no matter whether the button was pressed on a short frame or a long frame. For consistency, you'll want to put your falling acceleration in FixedUpdate, so you get the same ...


2

So after much effort I finally get it working, although I'm not sure if I did it the best way. Tried to do what Agent Tatsu suggested but it didn't work. I did something based on what I understood from the BlueRaja's answer. Basically I took every walkable tile of the map and "packed" each with its three adjacent tiles to form a "bigger tile". Each of these ...


2

You'll track two separate position variables here: your current on-path position, and your current actual position, shifted from the path. Store your offset from the start of the path when you first begin traversing: waypoint_index = 0; path_position = path.get_waypoint(waypoint_index); offset = actual_position - path_position; When you update your path ...


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