Tag Info

Hot answers tagged

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.


3

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


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


2

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


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

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


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


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


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


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


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?


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



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