Tag Info

New answers tagged

1

I'd go with splitting it into two triangles by connecting two opposite points and using two triangle-circle intersection tests. Those tests needs to cover three cases: A vertex of the triangle is inside the circle. The circle is contained within the triangle. An edge of the triangle intersects the circle. The first part is easy - just calculate ...


1

Voxels can be considered Axis Aligned Bounding Boxes (AABB)s. I suggest looking up the math surrounding collision detection and AABBs. It's actually quite simple as you can describe an AABB with just two Vectors (a maximum and minimum point). Here's a super simple example: http://www.miguelcasillas.com/?p=30 Of course AABB collision detection is really ...


0

I finally found the solution! Draw the enemies with respect to the map's position! Just draw the map, and then the entities on top of it a certain distance away from the map's top-left corner. This way, no matter how the map's position changes, the entities will stay put because they're drawn based on where the map is. The player is drawn on top of ...


-1

Stop using CollisionShapeFactory and create a custom CompoundCollisionShape made of BoxCollisionShapes for your table instead. And use a CylinderCollisionShape for your puck. Advanced Physics Wiki


-2

You could potentially use Vector4f's to calculate the bottom (and/or the entire areal of the object) to more easily calculate the boxes around the object. This will use its own methods and I am working on it right now. I will add a comment with the result (eventually).


0

Set the Person1 and Person2 SKPhysicsBody a little smaller than the SKSpriteNode. Then, add your Person1 and Person2 to update loop. You can do this by subclassing both SKSpriteNodes and then setting the name property to, for example, person. Implement a method in Person1 and Person2 that looks like this: //Objective C ...


1

The Wikipedia article on collision detection has this to say on the topic of matrices and collision detection; So we reduce the problem to that of tracking, from frame to frame, which intervals do intersect. We have three lists of intervals (one for each axis) and all lists are the same length (since each list has length n, the number of bounding boxes.) ...


1

Moving an object without a rigidbody or a character controller is also not optimized and will slow your game down, you can check Is Kinematic if you don't want forces acting on it and it will still be more optimized


0

This is pretty much the same solution as the other answers here. However, this handles the question of if the collision should happen in the first place (jump through platforms, ect). https://gist.github.com/izackp/67949de525305796244a public class CollisionUpdater { List<IPhysics> components; public CollisionUpdater () { ...


1

There was something wrong with my collisionNormal method, where the left and right vectors were actually flipped. This made collisions along the x axis actually push the objects into each other. if (wy > hx) { if (wy > -hx) { /* collision at the top */ return new Vec2D(0, -1); } else { /* on the left */ return ...


1

Here are two options you could consider; an easy one and one that you'd find in commercial games. Solution 1: Separate your movement axes If your objects are all rectangles (assumed to be axis-aligned), you could consider horizontal and vertical motion separately. This means your motion procedure will be updated to: // Horizontal movement x_previous = x; ...


0

Yeah, it's not necessary. When you detect a collision between A & B you should do something like: if (detectCollision(A, B)) { A.resolveCollision(B); B.resolveCollision(A); } This may not be how you do it, but you get the idea! If it is a problem that A has had it's values changed after resolving collision with B you could store the variables ...


0

A nice but lesser well known algorithm for this situation is called dimensional reduction. If you keep your list of rectangles sorted on one axis (say, x axis by sorting on the minimum x value of the rectangles), then collision detection just becomes a 1 dimensional overlap test on the y axis, for whatever overlaps there were on the x axis. Works better ...


0

In the worst case (for 40 AABBs) you'll need to do 780 tests. There's not going to be any problems with a simple 4 comparison test: a_min.x <= b_max.x b_min.x <= a_max.x a_min.y <= b_max.y b_min.y <= a_max.y If all of these are true, you have an intersection. At this point partition structures (like AABB trees) are not necessary at all. You ...


3

You may want to consider looking to spacial partitioning, such as a Quadtree. In a nutshell, you would be dividing your world into sub-sections, and only check collisions between objects that are inside of the same sub-sections, greatly improving the complexity.


0

I'm guessing you want to know how to do the collision-detection. For a simple game something like this could be done: (Note, this is just pseudo-code, not necessarily correct syntax and may also contain bugs) const int LEFT = 0, RIGHT = 1, UP = 2, DOWN = 3; // This could be done better using enum if you know about that bool intersects(Sprite s, int x, int ...


2

Rigidbody.isKinematic If isKinematic is enabled, Forces, collisions or joints will not affect the rigidbody anymore. The rigidbody will be under full control of animation or script control by changing transform.position. Kinematic bodies also affect the motion of other rigidbodies through collisions or joints. You can toggle this on/off in the Inspector, ...


0

Your constrain function seems to be flipped. You call m.constrain(p); which is going to call: // stops 'obj' from leaving 'this' (except that you shouldn't be setting variables of *this*) this.constrain = function(obj) { if(this.x > obj.x) { this.x = obj.x;} if(this.y > obj.y) { this.y = obj.y;} if(this.x + this.width ...


0

Collision detection shouldn't depend on input. You should aim to make your movement and collision systems as generic as possible. Not only that but I'm seeing an issue with the logic that happens during your frame. You seem to be doing something along the lines of: //Detect input //Detect collision //Move according to facing direction //Draw ...


0

The Separating Axis Theorem might be what you're looking for. Writing collision detection using SAT is easier than it seems and allows you to calculate handy things like where exactly they collided as well as the minimum translation vector. Highly recommended for shape collision detection.


0

If you want to check which of your body sides collided with obstacles, you can create your box-shaped body consisting of four b2EdgeShape sides having independent fixtures instead of single b2PolygonShape (in case you are using b2PolygonShape). In this way, while your are checking for contacts, can easily determine which fixture of my body is currently in ...


0

Here's why you probably don't want to use a rounded rectangle to try to fix your problem: Now, getting stuck on the edge like that is probably just as frustrating, if not more, than not being able to move right at all. I think you probably want to employ some error correction when you move. What I mean is, when your character moves, let's say, right, if ...


-1

I recommend using some middleware, so that all these kind of things are worked out for you. Otherwise, Yes, this is a good idea, you can cheaply rule out certain intersections and avoid an expensive test. This is referred to as a bounding box. Using some middleware will mean this is worked out for you.


0

Here is an optimized version of the above which I use for GPU: device float rayBoxIntersect ( float3 rpos, float3 rdir, float3 vmin, float3 vmax ) { float t[10]; t[1] = (vmin.x - rpos.x)/rdir.x; t[2] = (vmax.x - rpos.x)/rdir.x; t[3] = (vmin.y - rpos.y)/rdir.y; t[4] = (vmax.y - rpos.y)/rdir.y; t[5] = (vmin.z - rpos.z)/rdir.z; t[6] = ...


1

There are two steps to solving this problem. First you need some extra data on collision. When two objects collide you want to know how far they've collided into each other. After that you want to move the two objects backwards. Depending on how accurate you want it you could just take the amount that they overlap, divide it in half and then just move ...


0

I think that the author is describing how to calculate a bounding sphere in a (rather poor, IMHO) roundabout way. I skimmed over the text you linked to and it doesn't make any sense to me, either. The basic concept of a bounding sphere is that the distance between the center of the object and any point on the sphere is always the same. So all you need to ...


0

Collision resolution is no easy beast. You need to take a step back and realize that you're going to need to simulate some simple physics. Game physics don't have to be super accurate and you can tweak gravity and resultant forces however you want but you need a solid framework to build off of. I recommend that when handling collision resolution you have a ...


2

Approach B is what you want. With Approach A here's a possible problem: //You have two balls //Ball A moves //Ball A is now colliding with Ball B //Ball A and B get forces applied When in reality Balls A and B are very close but have the exact same velocity! What should happen (and what you would get with Approach B) is: //Ball A Moves //Ball B Moves ...


0

I guess the problem here is the so called Tunneling. Tunneling happens when an object moves to far in one update loop and therefore the collision is never detected, as it "jumps over" the other object. There are several ways to solve this: Continuous Collision Detection: Instead of checking for an overlap at the current posiition, you could use the way ...


1

I'm lazy, so here is the way I'd tackle this issue: it would be by coupling the graphics with a collision/physics engine. You could try and find a basic collision engine for your language and implement something like this for your collisions and graphics: The image is composed with square sprites images; here is the colour coding (note that the first row, ...


0

Property replication (which is what Photon does) and physics don't go well together. For first-person shooters, this is okay because all physics needs to be used for is keeping the player from going through walls and some local raycast detection. Complex physics where objects simulated on multiple computers are hitting and bouncing off each other leads to ...


1

This is a classic collision detection problem. Thinking about it in pixels isn't the right way of going about it though. What you need to do is have a geometric representation of your player and the boundaries of your tile map. This might be as simple as just having a bounding box on your player and on each tile. When the player's bounding box intersects ...


0

Below I've posted something I mocked up going for deformable pixel terrain. You may be able to get something from it... You may not... Either way, It can obtain the pixels of an image around the mouse position. The names are pretty self explanatory but if you don't understand something, post a comment here. using UnityEngine; using System.Collections; using ...


1

Looks like you're mixing 3D & 2D physics. You're using OnCollisionEnter2D, which triggers when 2D colliders hit each other. But then you're using Physics.Raycast, which casts rays against 3D colliders - so it won't be able to detect the two colliders that triggered the event, or any similar colliders in your scene. Maybe you want Physics2D.Raycast?


0

Take a Look at Texture2D.GetPixel You can find the contact point on the collider and then map that to the specific point on the texture.


1

This is how I'd do it: Generate convex hull from all planes Note: this includes both light frustum and scene AABB planes, so there should be a total of 12 planes Note: make sure all planes have matching orientation (normal outwards or inwards - doesn't matter much but it has to be consistent across all data and functions) Intersect every three planes ...


0

For many collisions, there will be several contacts to resolve. This is why you're getting multiple calls to your player.destroy(). I don't know what you're doing in the destroy method, but you shouldn't destroy any Box2D bodies of fixtures in there, as they might be needed for other preSolve calls. What you could do is instead of immediately destroying ...


0

Firstly, your question is very unclear. It doesn't have all the necessary information. Nothing at all in fact. Try to be a little more informative or precise in the future. When two bodies collide in Box2D there are numerous collisions. Collisions in Box2D are really the fixtures which are used to detect when a collision occurs. Collisions can happen in ...


0

Didn't realize it was as simple as just adding to the if statement. I thought I had already tried that. func didBeginContact(contact: SKPhysicsContact) { var firstBody: SKPhysicsBody var secondBody: SKPhysicsBody if contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask { firstBody = contact.bodyA secondBody = ...


1

Swept object collision detection can be challenging but there are some common solutions. One way is when testing two objects, using the concept of relativity you can set up the math such that one object gains the motion of the other, so that its moving object vs a static object test. Another way is if you use something like MPR or GJK to do collision ...


0

I'll try a semplified answer. Assuming you store previous frame time and position (and rotation) calculate point X interpolte dT = frameTime * FrameDistance/(X-PositionC1atFrameA) Check position of other circle C2 at dT (check if it intersect C1) Calculate Rot C1 and Rot C2 at dt finaly apply your logic (points 2,3,4) EDIT : Found a detailed analisys ...



Top 50 recent answers are included