Tag Info

New answers tagged

0

Of the methods you listed, the pixel perfect is the only one which can solve your exact problem. That is, unless: The curved line is defined by an exact formula you can use in checking You create a series of boundary lines that Approximate the curved line, and check for the crossover of any vector. Hope that helps! :)


4

Use the Minkowski sum A good way to solve this problem is to consider the intersection between a line of motion (v) translated to the origin (v') and the Minkowski sum of A rotated 180 degrees at the origin (A') and its obstacles (just B in this case): A' ⊕ B. In the following picture I place A smack-dab in the origin of an arbitrary coordinate system. ...


4

You don't need OOBs and you don't need to use time-stepping collision detection. Just use the normal AABB swept test, see this link. In essense it does exactly what you have in your diagram: the moving AABB is "swept" from start point to end point and then that is used for collision detection against other, static AABBs. If you are worried that this swept ...


1

First thing to note is that you can convert the box-box intersection test for AABB to a box-point intersection test by expanding one box and shrinking the other to a point. In particular if you have box A centered at c_A with width w_A and height h_A (and similar for box B, then A and B intersect if and only if the expanded box with center c_A, width ...


3

You will need to first decompose the movement into smaller steps and use that information to calculate a high-level AABB. If the large AABB's intersect, you can then check the smaller steps to be more accurate. Estimating whether or not there may have been a collision by checking AABB (or OOBB) using just the starting and ending positions can miss ...


2

You should also use relative speeds for the collision check so one AABB is "static" and the other move at a speed of its own speed minus the speed of the "static" one. The fastest way to see if they may intersect is to just expand the moving AABB with the speed. for example the AABB is moving right with 0.1 x/frame, then you extend it so the left edge ...


5

OBB - Oriented bounding box. Here's a tutorial Effectively, a bounding box aligned with the Velocity vector of object A as the y-axis (up). It's width and height can be calculated by the starting and ending points of object A. You then compare this with the AABB of object B (treating it as an OOBB), and your golden. If you're just looking for a quick ...


2

You will have to decompose the movement into smaller steps of movement. For example: You want to decompose the movement using the greater componen (in this case, X-axis), and then check for collision in each step. This might look too expensive, but take into account that an object moving faster than it's own width each cycle will be EXTREMELLY fast, so ...


1

You probably need to check for collision first, then check for depth. You can get the wall you are colliding with using wallHit = instance_place(.., .., oWall) then compare depth with wallHit.depth. Since you are checking collision twice, once for movement on each axis, you will need to check twice just in case there is a different collision result in each ...


1

I think these two lines are not needed: Subtract(a,&entities[target].pos);// Make it relative to the obstacle model ... Subtract(b,&entities[target].pos);// Make it relative to the obstacle model I don't see why are you adding them. I think that if you remove them it should work as intended. EDIT: when you calculate the normal to the triangle ...


0

This might happen because you handle every collision separately: There are two collisions in one frame competing against each other. The floor collision says correct the box up, the line collision says correct it down. As you can see the floor collision loses. What you can do is to implement a sequential solver which incorporates every collision between all ...


0

SOLVED! Ok so the idea to check if our player body left the body of our path is to count borders playerbody passes. So in contactlistener we make beginContact to add one to some int variable (lets say bordersPassed) and endContact subtracts one from it. So when our player is inside path this variable will always be bigger than 0. When it leaves path it will ...


1

The correct design choice here would be making one script and attaching it to the menu elements (I assume buttons) and define what each button will do on OnCollisionEnter() or OnMouseButtonDown(0). The main idea here is to differentiate clicks based on the name of the object that is being clicked on. void OnCollisionEnter(Collision col) { ...


1

Yes, it's common to cap GJK to small number of iterations. This is because the algorithm is most limited by numeric precision. Also I should note that some of Casey's optimizations don't actually work in practice if you need really accurate results. For graphics culling and whatnot, perhaps this is a non-issue, for collision detection in a physics engine ...


0

OnCollisionEnter(Collision collision){ if(collision.gameObject.name == foo){ //do foo } else if(collision.gameObject.name == bar){ //do bar } }


1

I usually use a transform hierarchy like this: Entity Object -> Visual -> Collision The "Entity Object" is at unit scale (1,1,1) and contains the rigidbody and whatever the "main script" for a particular entity is. This keeps the inspector clean and means the transform viewed by the main script is predictable. The Collision object is also kept ...


0

The method I use is called barycentric interpolation. I would write a guide how to do it, but I don't think I could possibly sum it up better than this tutorial.


0

I would reccomend removing your box collider and then add it back again. It will automatically resize to fit your texture. It looks like it is a bit off to me. The ground detection looks fine, but both the corner circle colliders are too low. This will cause unrealistic looking collision detection, unless you have reasons for the collider offsets.


0

I would add a slippery physics material then adjust the friction to fit your game. It should fix any hang ups.


0

There exists a manifold from the time BeginContact is called just up until EndContact is called. When EndContact is called the manifold is no longer valid. This means you can store the b2Contact pointer once BeginContact is called. For every game loop that EndContact is not called you can access the b2Contact pointer and query the manifold. This way you ...


0

What you need is the vector of the shortest distance between the Wall and the balls center. More generally, you seek the distance between a point and a line. Paul Bourke has given a general solution to this well known geometry Problem on his website: This note describes the technique and gives the solution to finding the shortest distance from a point ...


0

You were right about checking it before it collides but the handling collision algorithm you code will not solve it. As it doesn't handle all the case that can occur. Lets say that the player comes and grounded on the top of the platform. Yes the case of: if(Position.Y < OtherObject.Position.Y){verticalPoint = OtherObject.Position.Y - BoundRect.Height;} ...


0

All collision detection methods can benefit from pruning the list of objects to test before testing. One of the ways is to partition your world so you can query the objects that may intersect with some area (false positives are allowed) then only do the collision test on those objects. For example store the axis aligned bounding box in a grid and knowing ...


0

Your normals are supposed to be the face normals of a polygon. If your vertices are an oriented array in counter clockwise order, then you can easily compute the normal of a face by a 90 degree rotation. So if we have an edge on a polygon made of the vertices a and b, we know that the edge is oriented from a to b going around the polygon in CCW order. To ...


1

You need to change the collision of a ball against an infinitely thin line to an infinitely small point (ray) against a thick segment with two round ends You transfer the ball's thickness to the segment. Both end points become circles. The collision then becomes a 2D ray-cast operation.


0

I have looked into your code and I could see some wrong procedures ( I think , I might be wrong though ) but I will try to look more into it to see what are its problems . However , since your main goal is to stop the rectangles from intersecting each other , I have another way that works well ( mostly ) and I think is more efficient than your algorithm . ( ...


0

You can try allocating an array of pixels composing a bitmap of each getRGB() values of each individual pixel. Than compare the values with an if statement as the borders of the tile are a separate color value than that of what the tile represents(water, sand, grass). That for a basic isometric grid. Or you can have two layers of the map itself. One layer ...


0

Ken's answer notes: The 9 axes are made up of cross products of edges of A and edges of B It's somewhat confusing to refer to the edges, as there are 12 edges compared to 6 normals, when you might as well use the three main normals for the very same output - the edges are all aligned with the normals, so I recommend using them instead! Also note that ...


0

You call the player's Update() function 3 times per Main.Update(), where you probably want to call it only once. Calling it 3 times will presumably attempt to move the player 3 times per frame, only doing a collision test with a single object for each of these three movements, so that each subsequent Update() can move through the previous obstacles in the ...


1

Instead of using Mathf.Atan(y / x), which can only return angles between [-90..90] degrees, then compensating for angles outside that range by adding 180 degrees, simply use Mathf.Atan2(y, x). Atan2 is specifically made for the task you are solving. From the Mathf.Atan2 docs: public static float Atan2(float y, float x); Returns the angle in radians ...


0

You just need the angle of collision? How about: Vector2 collisionAngleVectorToFirstEntity (secondEntityPosition.x - firstEntityPosition.x, secondEntityPosition.y - firstEntityPosition.y); I'm not familiar with Unity but that Vector is pointing from the second point to the first point so running that on collision gives you a angle although in the form ...


1

Pros Higher resolution should give the player more visual information about the game world. Everything will be clearer and more sharply defined. This should confer an advantage in overall situational awareness, which in an FPS is important. There should be no effect on game state as the game engine does not compute the position of objects and actors based ...


7

The resolution should not affect computation of simulation logic such as "where your bullet hit." Any reasonable game will divorce such simulation data from the final render resolution of the screen. That means the main thing you're talking about with respect to resolution is what the player sees. If all other things are equal, then a lower resolution ...


3

BoundingBox provides several Contains (MSDN) methods that return ContainmentType (MSDN). To test if an object is outside your bounding box, test for ContainmentType.Disjoint.


0

For Physics2D the method needs to be called OnCollisionEnter2D and both gameobject needs to have a Collider like BoxCollider2D or CircleCollider2D public class EnemyMovement : MonoBehaviour { void OnCollisionEnter2D (Collision2D col) { if(col.gameObject.name == "player_character") { Destroy(col.gameObject); } ...


2

You need to invert the logic of the test not the box itself. The bounding box can only describe a box. Whether that is a rectangular solid in space or a rectangular hole in infinite space is up to the test performed.


1

Sticking to walls is a problem mentioned in this Unity learning module around 8:45, and they set the friction of the ground to zero to solve it. However, they don't address the sliding down slopes problem. Option 1: Give the character's body a frictionless rectangle collider that is just wider than the circle collider at it's feet, with its bottom ...


1

For completeness, I'll document the "reinventing the wheel" approach. I recently wanted to do this too, but I wanted to do it statically (due to some code-structure decisions made before that I didn't want to break). So I didn't want to create a sensor body and World.Step, as previously suggested. Instead, I figured that a convex polygon intersects with a ...



Top 50 recent answers are included