Tag Info

Hot answers tagged

4

Any easy way to do this is to form your cloth to approximate the surface as many small spheres. This will work if you have a fairly good particle size to edge-length ratio. To avoid a silly N^2 collision detection algorithm you can use a simple implementation of spacial hashing. First lets talk about spatial hashing for a discrete point. You take it's ...


3

To avoid brute-forcing, you could store the coordinates of your objects in a three-dimensional tree data-structure like a kd-tree or an AABB tree. These data-structures are very efficient at getting all objects withing a certain box-shaped area. To get all objects within a sphere-shaped area, you could first get all objects within a box which is large enough ...


3

For your first question you can optimize your method by only checking collisions with the border bubbles (only the bubbles that are actually exposed and not ones that are entirely surrounded). However, you can optimize this even further by using the fact that you know the coordinates of the bubble to find out approximately (or precisely, with some math) ...


3

Create an invisible box in front of the fan. Then check if some object is inside that box. Apply movement to that object. This can be done in unity quite easily. Create Empty gameobject Select the new gameobject Add Component-> Mesh -> Mesh filter Select from inspector -> Mesh filter -> mesh and set it to "cube" ( or what ever shape you want ) Add ...


3

Figuring out the correct solution to multiple collisions between overlapping (or perfectly aligned rectangles) is not trivial, and most solutions will have problems. I'm not even sure if there is an actual correct solution. Reading this question made me think that the problem could be solved by not letting the problem exist in the first place! "The problem" ...


3

One thing you can do is not let the character travel diagonally when the path crosses the corner of a wall. The character is free to travel diagonally out on the open, but not next to a wall. This is done in your a* algorithm.


3

Yes you should factor the size of the character into the A* calculation. There are basically two ways you can either make your character larger, which complicates the computation. Alternatively you can make the wall wider and pretend your character has 0 width.


2

getBoundsInParent() returns the bounding box around the shape — a rectangle. The built-in intersects() check works only for rectangular shapes, not for circles, polygons, etc. For these, you'd need to implement the check yourself.


2

If you have a list of entities or a list of potions which you loop through, you can simply remove the entity from the list. This should be standard practice anyway, as this makes it extremely easy to add more items without assigning loads of variables.


2

I admit I've never successfully written a collision resolver, but I have a suggestion. Your problem is that you have two valid contacts that resolve a collision between the circle and a rectangle. On their own, each contact will solve the collision, but when there are two contact occurring in the same cycle you will have to pick one. You can't apply both ...


2

Several possibilities : 1) use small collision maps for each different tile. It does not need to be very precise, small maps like 8x8 might be enough (depending what you need). You can do some interpolation to smooth it out. Here is an example : Instead of using only occupied / non-occupied state for the collision map, you might also consider using ...


2

Your problem is that you are checking for a collision and then stopping, this means that if your frame places you to far into an object you are now stuck. To solve this you have to solve the equation of exactly where both object were when they hit one another. So you have to find where the following is true: |t*v1+p1-t*v2+p2)|=|r| where t is time v is ...


1

Remember that SpriteKit's physics system is based on "SKPhysicsBody"s, which are added to "SKSpriteNode"s. Those physics bodies, however, needn't be attached to visible nodes. The simplest method is to create a SpriteNode with no actual sprite or visible body, add it as a child to the area you want on the visible shape, and categorize it differently from ...


1

A simpler way, that will also speed up your program, is to check if your circle is moving towardas the other circle before check for a possible collision. You can do in it in this way: vector2 p; p.x = other.position.x - your.position.x; p.y = other.position.y - your.position.y; if(p.x*yourSpeed.x + p.y*yourSpeed.y > 0 { //check for collision; } look ...


1

I will assume that the player collides with the ground only on the middle point. We can do an approximation of the height of the terrain at a given point with this: double x = 4.6; double relativeX = x / widthBetweenPoints; int terrainIndex = Math.floor(x); double ratio = relativeX - terrainIndex; int y = Points[terrainIndex] * (1 - ratio) + ...


1

Collision doesn't need to care about tiles at all. If a tile is just a shape of lines, your "tile collision" is really just collision against those specific lines. You can also use collision against arbitrary shapes defined by mathematical functions - like curves - which are represented by tiles. Tile collision in this case means determining which tiles the ...


1

For a situation like this you'd be better off using something like a OverlapSphere. Or if you're using 2D, you have a few more options with the OverlapAreaAll or the OverlapCircleAll methods. All of these methods are going to return a list of colliders that intersect with the shape you choose (sphere, circle, rectangle). These have the additional benefit ...


1

There's nothing built in that'll allow you to view gizmos in a released game. However, you can create your own debugging viewer by using the LineRenderer. Personally I would create something like a DrawBounds method that accepts the Bounds property of the collider.


1

You need only simple collision detection for something like this: You could just compare the X-coordinate of the nearest wall with that of the player when the player throws a punch. Something along the lines of if (wall.x - player.x <= 50 && wall.x - player.x > 0) { // The wall is in a good position! } else { // The wall is out of ...


1

A high-powered family of algorithms you may need to look into are all "clustering" algorithms. These algorithms find groups of data points which could be Cartesian points or any other property (color, weight, etc.). See K-means Clustering for one such algorithm. It's not a terrible algorithm to run in real-time, depending on how many entities you need to ...


1

The other's have suggested kd tree's but I think that a more appropriate data structure for you would be using an R-Tree which is specifically for retrieving collections of near objects. You can find out more here: http://en.wikipedia.org/wiki/R-tree


1

A kd-tree or AABB tree is a great data structure, if the objects are going to be static, or mostly static, as they are not cheap to update. But it seems like those structures would be more useful to find what's around a certain point, rather than to figure out the largest cluster of objects. For that, I'd use a simple grid. Have each object register itself ...


1

The way I might approach it is to create a list of all possible hex center locations during the initialization stage before the game loop starts. Then during the game loop, if there is a mouse click within 1.5 tile radius (or whatever dist you think is approp) of a white tile, simply iterate the list and find the closest list Point to the click point. If the ...


1

As per Andy's comment: Nevermind, I fixed it. I just had to take out the p.setCenterX(center.x);p.setCenterY(center.y); out of the render function.



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