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 ...


3

By doing a preview with time increments different from your process, you're bound to have differences. For example, consider these extreme cases: You simulate a preview with 1 point per second: on the first step, your Yvelocty becomes -500 + 300 = -200, making it as if you started your jump with a speed of only 200 while it should be 500 in reality. You ...


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 ...


2

the accuracy should be in 1-2ms intervals You are out of luck here, getting high and steady frame-rate in WPF is impossible by design. Still, you can get decent 60Hz, and anything above requires high-frequency display anyways — I expect those to be rarity in a business environment. I am planning to use writeable bitmap 800x40px. D3DImage should be a ...


1

Here is a simple solution on how to implement moving platforms without parenting or using the default friction. Since the requirement was not to use any friction we have to create a physical material and set the friction to 0 and add it to the rigidbody of our character (player). For 2D it must be a RigidBody2D, and it must be Dynamic since we want forces to ...


1

[EDIT: I have written an answer above which solves the question without friction. I keep this one however since it is still valid in many situations and the comments give some context to the solution.] As you described it the player should follow along with the platform automatically - you are using physics and that should take care of it. Ok, I am not an ...


1

I wanted to show what applying Keelhaul's answer to a godot script would look like to try and add clarity to what the issue was. The Following is my modified script. extends Node2D var arcPoints = 120.0 #total number of points to draw var arcFPS = 60.0 var PPF = 2.0 #points per frame var startYvelocity = -500.0 var velocity = Vector2(200.0, startYvelocity) ...


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

We can use the Tilemap's Grid to convert the world-space bounds of our selection rectangle into grid coordinates within the map: LayoutGrid grid = tilemap.layoutGrid; Vector3Int bottomLeftCell = grid.WorldToCell(bottomLeft); Vector3Int topRightCell = grid.WorldToCell(topRight); Vector3Int min = Vector3Int.Min(bottomLeftCell, topRightCell); Vector3Int max = ...


1

The default rigidbody.AddForce applies the force facing the center of mass of your rigidbody, so it will never directly cause any rotation. But there is also the method rigidbody.AddForceAtPosition(Vector3 force, Vector3 position, ForceMode mode). This method can be used to apply forces to an object which are off-center and thus will result in a mix of ...


1

Some semi pseudo code Change SelectDirect.Up to SelectDirect.Vertical and SelectDirect.Right to SelectDirect.Horizontal if (Mathf.Abs(selectionDirection.x) == 1) { selectDirect = SelectDirect.Horizontal; fixedY = selectedPositions[0].y; } On the case switch Horizontal you can compare SelectedPiece.position vs Vector2(SelectedPiece.x, fixedY). ...


1

If there is no shearing in play, then Atan2(matrix[0].y, matrix[0].x) gives you the angle of rotation about the z axis in radians. This is because the first column gives you the direction that the local x-axis points after rotation. If it's (1, 0) then there's no rotation (or a multiple of 2 pi). If it's (0, 1) there's been a 90 degree rotation, etc. Atan2 ...


1

It looks like you're trying to point your local right vector toward the target, but you're assigning a position instead of a direction. transform.right = (Vector2)targetPosition; First, get the direction from your current position to your target. var targetDirection = targetPosition - transform.position; Then you can either assign this directly as you were ...


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