_id
int64 0
49
| text
stringlengths 71
4.19k
|
---|---|
18 | Handling strange physics behaviour while sliding between coplanar surfaces We've got a character setup based around manually resolving collisions, and we're using bullet to do so. Our characters have a kinematic rigidbody to push things around, but their movement and positioning is done using a separate (pair caching) ghost object. Every physics tick we iterate over all contacts for that ghost and resolve collision either by depenetrating 100 when it's ground, or by depenetrating gradually not at all with walls or other characters. We then apply our ghost's new position to the kinematic rigidbody so that can interact with other physics objects. Unfortunately, when moving around a flat world made up of a bunch of coplanar blocks, when the characters moves from one block to another it will often do one of two things Fall through the cracks Get bumped upward a significant distance (we're talking up to half a unit meter with a character that is 2 units meters tall) Debugging this tells me sometimes these contact points are unexpected, and not something I want to resolve by depenetrating 100 . Gravity moving the character downward can result in a contact point that is closer to the side of the terrain block than the top, and it will give you a normal distance accordingly (blue arrow). Resolving that with 100 depenetration will just push you in between the blocks, while not counteracting the gravity forces. This would explain the falling through the cracks. But I don't know why I sometimes get contact points with normals pointing straight up, but with a distance that would place the collider far above the ground (purple arrow). I've come to the point where I feel like my only option to handle character movement like this is by not colliding with the ground at all, and just spherecast downwards at the character's position on the horizontal plane just to place it down on the ground properly. Now obviously I want to get rid of this behaviour. And seeing how you don't see this happen in many games, I'm lead to believe others have solved this issue somehow. Has anyone here encountered similar issues, and how did you go about fixing them? |
18 | Weird issue in collision resolution of non static bodies I'm a bit of a beginner in engine development, so I decided to write my own engine from scratch so I could learn more about what happens under everything. I've been progressing fairly well, except the physics engine side of things have been giving me a bit of a headache. Here's a gif of what I mean Essentially, the engine works just fine as long as the player is not colliding with another non static body from either above, or from right to left. Here's my collision resolution code written in go package resources import ( "game pidgeot socket ecs" "github.com bxcodec saint" ) type PhysicsSystem struct Hub Hub func (system PhysicsSystem) Loop() entities, err system.Hub.World.AllEntitiesWithComponent(ecs.CollisionComponent) if err ! nil return for e, range entities apply impulse c p, system.Hub.World.GetComponent(e, ecs.CollisionComponent) c ( c p).( ecs.Collision) p p, system.Hub.World.GetComponent(e, ecs.PositionComponent) p ( p p).( ecs.Position) if c.WithGravity Add gravity c.ImpulseY saint.Min(c.ImpulseY 1, c.MaxSpeedY) apply impulse p.NextY p.Y c.ImpulseY p.NextX p.X c.ImpulseX resolving collisions for e1, range entities c1 p, system.Hub.World.GetComponent(e1, ecs.CollisionComponent) c1 ( c1 p).( ecs.Collision) if c1.IsStatic continue for e2, range entities if e1 e2 continue system.ResolveCollision(entities, e1, e2) moving entities for e, range entities p p, system.Hub.World.GetComponent(e, ecs.PositionComponent) p ( p p).( ecs.Position) if (p.X ! p.NextX p.Y ! p.NextY) p.X p.NextX p.Y p.NextY system.Hub.broadcast lt system.Hub.World.GetComponentMessage(e, p p) func (system PhysicsSystem) ResolveCollision(entities map ecs.EID ecs.Component, e1 ecs.EID, e2 ecs.EID) c1 p, system.Hub.World.GetComponent(e1, ecs.CollisionComponent) p1 p, system.Hub.World.GetComponent(e1, ecs.PositionComponent) c1 ( c1 p).( ecs.Collision) p1 ( p1 p).( ecs.Position) c2 p, system.Hub.World.GetComponent(e2, ecs.CollisionComponent) p2 p, system.Hub.World.GetComponent(e2, ecs.PositionComponent) c2 ( c2 p).( ecs.Collision) p2 ( p2 p).( ecs.Position) resolve y axis collidingX IsOverlapping(p1.X, p1.X c1.W, p2.X, p2.X c2.W) collidingY IsOverlapping(p1.NextY, p1.NextY c1.H, p2.NextY, p2.NextY c2.H) colliding collidingX amp amp collidingY if colliding direction func (impulse int) int if impulse lt 0 return 1 else return 1 (c1.ImpulseY) overlap CalculateOverlap(p1.NextY, p1.NextY c1.H, p2.NextY, p2.NextY c2.H) p1.NextY (direction overlap) c1.ImpulseY 0 c1.IsJumping false resolve x axis collidingX IsOverlapping(p1.NextX, p1.NextX c1.W, p2.NextX, p2.NextX c2.W) collidingY IsOverlapping(p1.Y, p1.Y c1.H, p2.Y, p2.Y c2.H) colliding collidingX amp amp collidingY if colliding direction func (impulse int) int if impulse lt 0 return 1 else return 1 (c1.ImpulseX) overlap CalculateOverlap(p1.NextX, p1.NextX c1.W, p2.NextX, p2.NextX c2.W) p1.NextX (direction overlap) for e3, range entities if e1 e3 continue c3 p, system.Hub.World.GetComponent(e3, ecs.CollisionComponent) p3 p, system.Hub.World.GetComponent(e3, ecs.PositionComponent) c3 ( c3 p).( ecs.Collision) p3 ( p3 p).( ecs.Position) collidingX IsOverlapping(p1.NextX, p1.NextX c1.W, p3.NextX, p3.NextX c3.W) collidingY IsOverlapping(p1.NextY, p1.NextY c1.H, p3.NextY, p3.NextY c3.H) colliding collidingX amp amp collidingY if colliding system.ResolveCollision(entities, e1, e3) Anything I could do to solve that issue? |
18 | How to simulate cylinder shape in collision detection? AFAIK, many physics engines like Physx and Havok don't incorporate cylinder as basic shape because it is expensive than sphere, box and capsule. But bullet engine does incorporate cylinder as a basic shape. Do they found any fast algorithm to simulate the cylinder and what is that? |
18 | Ellipsoid v. Box collision detection I'm trying to write some collision detection code. ATM i have the code properly resolving Ellipsoid v. Ellipsoid collisions, and Box v. Box collisions, but Ellipsoid v. Box collisions doesnt work. In general how do you test for interesection between these two. What i've been doing is Finding the closest point on the ellipsoid to the box, and vice versa. vector3 closestVertexOnBox Closest vertex on the box to the ellipsoid vector3 closestPointOnEllipsoid Closest vertex on the ellipsoid to the box In this case ( ellipsoid v. box ) you have 4 axes. The axis from the center of the circle to the nearest point on the box. The X,Y,Z standard axes ( assuming its an AABB ) Put them all in an array vector3 axes normalize( closestVertexOnBox ellipsoid.origin ), unitX, unitY, unitZ Then for each axis in that array, Project the vector from the center of each shape, to its vertex closest to the other shape onto each axis to find the projected half widths. float minOverlap infinity vector3 overlapAxis for each axis in axes float prjBoxHalfWidth Dot ( axis , closestVertexOnBox box.origin ) float prjEllipsoidHalfWidth Dot ( axis , closestPointOnEllipsoid ellipsoid.origin ) If the sum of any of the projected half widths are smaller than the projected distance between the two, then their is no collision float prjDistance Dot( axis , box.origin ellipsoid.origin ) if(prjBoxHalfWidth prjEllipsoidHalfWidth lt prjDistance) return no collision Now get the axis with the least overlap out of all of them float overlap prjBoxHalfWidth prjEllipsoidHalfWidth prjDistance if(overlap lt minOverlap) minOverlap overlap overlapAxis axis Then resolve the overlap ellipsoid.origin overlapAxis minOverlap 2 box.origin overlapAxis minOverlap 2 Thats pretty much my ( pseduofied ) code. If thats good, then i might have an error, but thats wrong, then what am i not taking into consideration or forgetting. |
18 | relationship between eye height and collision body in UDK We are using the UDK in a research lab setting so we must understand exactly how tall users feel in the virtual world (camera position). By Googling and digging through code, we have discovered the BaseEyeHeight parameter and also the dimensions of the collision cylinder (CollisionHeight). We attempted to set these using Remote Control and could not deduce the relationship between the variables. For one thing, it seems that BaseEyeHeight has a ceiling. We cannot set it arbitrarily high but the height that is allowable seems to be dependent on the height of the collision cylinder, though it can be higher than the cylinder. Is there a ceiling for the eye height? Secondly, the height we set for the collision cylinder does not seem to match the height of an object in the world that should be the same height. Is the collision cylinder in the same units as the rest of the world? Is there some padding that I am not accounting for? Finally, BaseEyeHeight does not seem to be the height from the ground. I read somewhere that it should be the height from the center of the cylinder. Is this true? I would expect the eye height to be a bit lower than the actual collision height (as in the real world). Is this the case? The big picture problem is that we cannot find a diagram or detailed description of how these numbers relate to one another. Is there a comprehensive source we've missed? |
18 | GJK point in tetrahedron capping the number of searches? The very informative mollyrocket video has given me quite a lot to work with, but one thing that the video seems to suggest is that the algorithm should ideally run until it definitely determines whether or not there's a hit. I was of the idea that if there's no collision, it would be obvious by testing the dot product of the latest point against the search direction if it is not positive, then we did not pass the origin, so a tetrahedron which encloses the origin simply cannot be built. In cases where there is a hit OR a clear miss, the routine typically picks up less than 11 loops through. However, as I tend towards 'questionable territory' and the definitive hit miss is visually less distinct, there are times when the method apparently continues to pass the origin yet construct unsuccessful simplexes. Is it common to cap this kind of function at a max number of tries? Right now I am somewhat arbitrarily using the number of points in one shape times the number of points in the other shape in other words max tries len(shape1.pts) len(shape2.pts) It feels a bit hacky and I have to assume that the routine is geared towards simply running ad nauseum until it smacks into a clear hit miss situation. Has anyone experienced this before? Is this a problem or an anticipated safety measure in such an algorithm? If it needs to be done I'll gladly share some code, but I think it stands as self evident that it is kind of a longer read than most code snippets so I've abstained for now. |
18 | OBB vs rectangle quad plane with bounds collision detection response I am able to resolve collision between an OBB and a plane but can't get it to work when I introduce some bounds on the plane size. I want to have the plane of width and height dimensions defined by a normal and a position. The code for detecting resolving is fairly simple if the plane doesn't have any bounds function obbIntersectsPlane( obb, plane ) let r obb.size.x 2 Math.abs( dot( obb.right, plane.normal ) ) obb.size.y 2 Math.abs( dot( obb.up, plane.normal ) ) obb.size.z 2 Math.abs( dot( obb.forward, plane.normal ) ) let s dot( plane.normal, obb.position ) dot( plane.normal, plane.position ) if ( Math.abs( s ) lt r ) return overlap r s, vector plane.normal return false |
18 | Collision intepenetration and objects getting stuck (Unity) I am having what is probably a newbie problem with Unity, but for the life of me, I can't find a decent solution to it. In short my rigid bodies collide, but sometimes, they interpenetrate and stay stuck. I am looking for a solution that would either 1 stop the interpenetration from even happening 2 or at least eject the bodies to 'unstuck' the collision. By making the physics fixed step 0.01 instead of the default 0.02, I can avoid some of the interpenetration. However, that hardly sound like the proper way to fix this problem. Here is a screen shot of the bodies colliding. The car on the right is shown completely and you can notice that the ones behind have penetrated the others to some extent. To give more information that could be relevant There is no gravity All the objects have rigid bodies Their sizes are 3.5 x 6.8 and they are moving at 8 to 50 m s Each object has a conpounded collider made up of 3 box colliders If I change the fixed step to 0.01 there is a lot less more interpenetration (as I mentioned). Other physics settings do not seem to have any effect The object is moved by setting its velocity in the FixedUpdate function with rigidbody.velocity XYZ until there is a collision, then there is no more processing done in FixedUpdate at all. I detect the collision with OnCollisionEnter and set a flag. I haven't set any collision material, but I can't see that being a factor? Solved Thanks to everyone who helped me with the issue. There were a few factors in play. First, there was the scale. What I did to figure this one is create an empty scene and put 2 cubes in there. I varied the size and position of the cubes (from 68x35 to 0.65x0.35 for size and the position by factors or 10 as well) and attached a script to move them, with variation in speed by factors or 10 as well. So all else being equal (same size on the screen and time to cross it), the size of the objects elected a different response to collision big object got interpenetration, small ones none. I am not familiar enough with Unity to explain the cause of that, but it is reproductible. A possible second factor was the shape of my colliders and how it may be possible that they screwed up the ejecting part. The colliders I had were not overlapping, so I simplified them to 2 boxes in the shape of a cross. Finally I was setting the position of the objects manually in FixedUpdate and that caused some problems with interpenetration at lower scale (at higher scale, it didn't appear to matter). I changed that to work with the body velocity and it helped. |
18 | Collision causing First Person Controller to go haywire I have created a first person controller as an enemy in my game (Zombie). My character is an archer that uses arrows as projectiles that are shot with the following code if(Input.GetButton("Fire1")) shotForce 45f if (Input.GetMouseButtonUp(0)) Rigidbody shot Instantiate (projectile, shotPos.position, shotPos.rotation) as Rigidbody shot.mass shotMass shot.AddForce (Camera.main.transform.forward shotForce) shotForce 0f I have a script to parent the fired arrow to the collided object which works fine for most objects in the game, but my enemy object (Zombie) speeds up and moves all around the place on a collision, I'm new to unity, I've spent a few hours trying to resolve this with out success. I have a Rigidbody, Charcter controller and First person controller on the Zombie. I have a Rigidbody and Sphere Collider on the Arrow. The method I think is causing the problem void OnCollisionEnter(Collision collision) if (this.flying) this.flying false Destroy (this.GetComponent lt Rigidbody gt ()) this.transform.position collision.contacts 0 .point GameObject anchor new GameObject ("ARROW ANCHOR") anchor.transform.position this.transform.position anchor.transform.rotation this.transform.rotation anchor.transform.parent collision.transform this.anchor anchor.transform collision.gameObject.SendMessage ("arrowHit", SendMessageOptions.DontRequireReceiver) I think the issue is with the line anchor.transform.parent collision.transform Maybe there is a solution without parenting the arrow to the Zombie? I'm stumped at this stage any help appreciated. |
18 | Sprite Kit keeping character level with the terrain 2d endless runner I've been trying to figure this out exhaustively for the past few days and still haven't found an answer. I have an endless runner built using swift where the character is fixed and the terrain moves to the left. I have edge physics bodies on the terrain, and edge physics bodies that go up and down slopes. The problem is, if I want my character to collide with the ground without being pushed back by it, since the only thing that can make contact with an edge is a dynamic volume. My goal is to keep the character level with the terrain, (assuming they're not jumping). Even on slopes. I've tried ray casting using enumeratebodiesalongraystart, but can't seem to figure out how to get coordinates of where it intersects with the ground. I've tried having an edge body that is vertical, that intersects with the ground(two edge bodies cannot make contact in sprite kit). I've tried dynamic volumes. I've tried Static volumes. Nothing works. I'm not posting code here since I'm really just looking for a general answer to sort of point me in the right direction, but I'm coding in swift. Thanks in advance. Also I have the character in a different bitmaskcatagory than the terrain catagory and they are set up to recognize each other, and do if one of them is a dynamic volume physics body. |
18 | AABB Sweeping, algorithm to solve "stacking box" problem I'm currently working on a simple AABB collision system and after some fiddling the sweeping of a single box vs. another and the calculation of the response velocity needed to push them apart works flawlessly. Now on to the new problem, imagine I'm having a stack of boxes which are falling towards a ground box which isn't moving Each of these boxes has a vertical velocity for the "gravity" value, let's say this velocity is 5. Now, the result is that they all fall into each other The reason is obvious, since all the boxes have a downward velocity of 5, this results in no collisions when calculating the relative velocity between the boxes during sweeping. Note The red ground box here is static (always 0 velocity, can utilize spatial partitioning ), and all dynamic static collisions are resolved first, thus the fact that the boxes stop correctly at this ground box. So, this seems to be simply an issue with the order the boxes are sweept against each other. I imagine that sorting the boxes based on their x and y velocities and then sweeping these groups correctly against each other may resolve this issues. So, I'm looking for algorithms examples on how to implement such a system. The code can be found here https github.com BonsaiDen aabb The two files which are of interest are box Dynamic.lua and box Manager.lua. The project is using Love2D in case you want to run it. |
18 | Calculating radius during collision This picture is from one of Dirk Gregorius' presentations The original diagram has only one contact point (the red one). The r 1 and r 2 vectors are required to produce rotation while solving the contact constraints. I agree that the r 2 vector is correct, but I think that the r 1 vector should point towards the blue point (which I've added myself) It's not difficult to retrieve the blue point (just add the minimum translation vector to the red point), but I've seen contrasting depictions of what points the contact manifold consists of. Excluding the parallel edge edge case, should the contact manifold consist of two points (the deepest points of each shape) or just one? |
18 | Tiles and a walkable path My game a sidescrolling platformer. I've created my own Tile app which in the end export an xml file detailing what each 32x32 space (in the entire image) contains (environment, platform, etc.). I get how to use it for static things collision detection and quad trees and so forth but still have no clue how to use this map xml file for keeping my character on a path in my background image which in my case is a hill with lots of odd curves. Also, yes, there are tutorials on tile movement, but they are mostly movement from a top down view which is slightly more trivial to implement. 80 of the image in my game is just a pure background and the very bottom are bricks covered with grass with some weirder angles. The thing is, I can have mixed tiles of empty space and grass which contains a part of a curve so I don't know how I would want the player leg to interact with this. Can anyone give me an idea or an example? |
18 | Swift How do I detect the exact point at which two "SKPhysicsBody(edgeFromPoint " type physics bodies intersect in sprite kit I have two physics bodies attached to two separate sprite nodes using Sprit Kit. One is a vertical line and one is a horizontal line sprite with horizontal physics body spriteMatrix i j .physicsBody SKPhysicsBody(edgeFromPoint CGPointMake(0, tileSegmentHeight), toPoint CGPointMake(tileSegmentWidth, tileSegmentHeight)) spriteMatrix i j .physicsBody!.categoryBitMask self.surfaceCatagory spriteMatrix i j .physicsBody!.contactTestBitMask heroCatagory sprite with vertical physics body self.hero.physicsBody SKPhysicsBody(edgeFromPoint CGPointMake(self.hero.frame.width 2, self.hero.frame.height 2), toPoint CGPointMake(self.hero.frame.width 2, 20)) self.hero.physicsBody!.categoryBitMask heroCatagory self.hero.physicsBody!.contactTestBitMask surfaceCatagory What I'm want to do is test if they are intersecting on every frame, and if they are, return the x and y position of where they are intersecting. Is this even possible? |
18 | Half top down view collision and mechanics I'd like to create a game with a half top down (2d RPG) view (I don't know the exact name of it). It would be 2d, but I'd like to add 3d like collisions. For example If the grenade lands on the roof, it would roll down and fall. Or if it hits a wall, it would bounce back. I've never worked with this view, that's why I'm asking for advices for how to do proper collisions and physics. I don't want to use any external libraries. Thanks in advance! |
18 | What are the advantages and disadvantages of overlap testing and intersection testing? I have been looking for the advantages and disadvantages of both overlap testing and intersection testing, but I was only able to find a few disadvantages overlap testing may fail for objects moving very fast, and intersection testing makes assumptions that may lead to wrong predictions, such as a constant speed and zero accelerations. What are the advantages and disadvantages of overlap testing and intersection testing? |
18 | body entered signal won't emit when rigidbody collided to rigidbody I have multiple rigidbody object floating away in the space. When they hit each other, they push away each. I want to destroy object if they hit something, but connect body entered signal won't invoked when they impact each other func ready() connect("body entered", self, "destroy") func destroy(body) print("HIT!") queue free() How do I check Rigidbody hit something? |
18 | Simple Bounding Box Multiple Collision problem I'm making my first game, and in it I use a moving ball to hit static blocks (kinda like breakout). Basically, I loop through all of the static blocks on the screen each frame, update the position of the ball based on its velocity, and if it collides with a block, the ball will bounce back off of the block. If the ball hits one block exactly, then there is no problem whatsoever. But if the ball happens to hit two blocks at the same time (that is, it hits in between both blocks), it passes right through both of them no deflection whatsoever. (I know the looping is inefficient and I'm looking to correct that later, but if it has to do with the problem, I just hope someone can point to me why it is that the collision resolution fails when two similar objects are hit at once.) |
18 | Javascript canvas check if all recs on the screen overlap a new one So I know the AABB collision detection formula, however, this code does not work. Whenever I press space, a new square pops up. But this new square can spawn inside another, something that I do not want to happen. Here is a snippet of the code I think is going wrong var xTopsBotsYTopsBotsSquares Makes a randint() function. function randint(min, max) return Math.floor(Math.random() (max min 1)) min function checkForOccupiedAlready(left, top, right, bottom) if (xTopsBotsYTopsBotsSquares.length 0) return true for (var i 0 i lt xTopsBotsYTopsBotsSquares.length i ) var data xTopsBotsYTopsBotsSquares i if (data 0 lt right data 1 lt bottom data 2 gt left data 3 gt top) Do nothing else return false return true Makes a new square function makeNewsquare() var checkingIfRepeatCords true DO loop that checks if there is a repeat. do Makes the square x y positions var squareRandomXPos randint(50, canvas.width 50) var squareRandomYPos randint(50, canvas.height 50) Tests if that area is already occupied if (checkForOccupiedAlready(squareRandomXPos, squareRandomYPos, squareRandomXPos 50, squareRandomYPos 50) true) xTopsBotsYTopsBotsSquares.push( squareRandomXPos, squareRandomYPos, squareRandomXPos 50, squareRandomYPos 50 ) console.log(squareRandomXPos, squareRandomYPos, squareRandomXPos 50, squareRandomYPos 50) checkingIfRepeatCords false while (checkingIfRepeatCords true) |
18 | Efficient Collisions Iteration? My project has upwards of 3000 2D objects but not all of them collide with each other. Between each object that can collide, a CollisionPair is created and stored inside a flattened array. Currently, a MaxObjects is defined for accessing the flattened array. Unfortunately, when iterating over this array for collision checks, I get a lot of overhead from the for loop and null checks. Is there a more efficient way, both in memory and performance, to store and access CollisionPairs? Note Many of these objects are axis aligned boxes how does Minecraft handle these collisions? |
18 | How to create walls and rooms with Pixi I'm a JS dev but pretty new to Pixi and 2D developemnt so please bear with me as I explain this. I want to write a simulator for short path finding (for evacuation purposes). I decided to use Pixi.js for this since it seems capable of doing everything I need to do. I followed this tutorial to try to learn how Pixi works and if its right for this. The tutorial didn't seem to answer many questions I have and I still have some confusion. Before I dive into writing the code, I want to know how wall detection in Pixi acheived. Take the below map for example It is a 800 x 800 png file (where everything but the blue is transparent no grid lines ) that i can load into Pixi as a Sprite. I created it in Tiled editor. So it can be exported as a tilemap, JSON, CSV etc. When I export it as JSON, here is the file contents https pastebin.com zGh1XmR7 The blue boxes represent walls. I want to load in other various sprite objects so that it will look like this The people in the simulations cannot cross the blue walls and they cannot cross the pink circles (they represent danger zones). I intend to use easystar.js to find the shortest path to exits for the people sprites in the map. So my question is this, how does Pixi recognise the blue walls? Is it something I have to do when creating the tileset png? Like something defined in the JSON file for the tileset atlas? Maybe SVG? Or is there a pixi function to do this? Is this the best approach to doing this and is Pixi even the best way to do this? I'm looking for a tried and tested solution or a pointer in the right direction. |
18 | How can I run a Phaser engine game without a window? I'm currently creating a multiplayer game using the HTML5 framework Phaser. It's a game where zombies spawn on the map and players have to shoot them to kill them. The zombies target players that are closest to them. Currently, I'm having my an issue with my design strategy. I'm not sure if this type of game is possible with Phaser due to the movement tracking. At present, the client is handling all of the player movement, so whenever a player moves, it broadcasts it to the server which sends it to all of the other clients. However, I would like for the zombies and the bullets to be controlled by the server exclusively. The server then updates each client with the velocity of each zombie and their current position. My reasoning is that anything that isn't player input should be calculated by the server. This will prevent issues such as two clients saying that a zombie died at different times and then trying to communicate with one another, having bullets at different locations at the same time, or zombies spawning at separate times between clients. Here's an example of a zombie class function Zombie(game, data) this.game game this.id data.id Phaser.Sprite.call(this, this.game, data.x, data.y, 'zombie') this.anchor.setTo(0.5,0.5) this.animations.add('right', 0,1,2,3 , 7, true) this.animations.add('left', 4,5,6,7 , 7, true) this.game.physics.arcade.enable(this) this.body.collideWorldBounds true this.health data.health this.maxHealth data.maxHealth this.speed data.speed this.target this.game.player this.waiting 100 this.name "zombie" this.healthBary 20 this.healthBar this.game.add.sprite(this.x, this.y this.healthBary, 'player health') this.healthBar.anchor.setTo(0.5, 0.5) CollisionManager.addObjectToGroup(this, 'baddies') this.game.add.existing(this) Zombie.prototype Object.create( Phaser.Sprite.prototype ) Zombie.prototype.constructor Zombie Zombie.prototype.update function() this.updateHealthBar() this.moveTowards(this.target) Zombie.prototype.uTarget function(target) this.target target Zombie.prototype.moveTowards function(target) var x target.x this.x var y target.y this.y var mag Math.sqrt((x x) (y y)) var nx x mag var ny y mag this.body.velocity.x nx this.speed this.body.velocity.y ny this.speed if(this.body.velocity.x gt 0) this.animations.play('right') else if(this.body.velocity.x lt 0) this.animations.play('left') Zombie.prototype.updateHealthBar function() this.healthBar.x this.x this.healthBar.y this.y this.healthBary var p (this.health this.maxHealth) p parseFloat(p.toFixed(1)) this.healthBar.frame 10 (p 10) Zombie.prototype. damage function(amount) this.health amount if(this.health lt 0) this.kill this.die(true) Zombie.prototype.die function(points) if(this.game) this.game.baddie die sfx.play() WaveManager.onMap CollisionManager.removeObjectFromGroup(this, "baddies") if(this.healthBar) this.healthBar.destroy() socket.emit("kill zombie", id this.id ) this.kill() this.destroy() The problem is that I can't create a Phaser game object on the server (as it's running on a Linux server) because there's no window that can be used. The bullets and zombies need to be Phaser objects for the sake of collision detection, but I can't do that on the server. I know that I could create a vector of zombies and bullets server side that would have the information for each bullet zombie's position at any given time and then update the client, but then I wouldn't be able to use the CollisionManager in Phaser. Right now, it seems like my only solution is to create my own collision detection system. Are there any alternative ideas? |
18 | Collision 100 avoidance implementation I'm an absolute beginner with game development and all I know about collision avoidance resolution, I learnt it on or through this site in the past week... so don't hesitate to correct me if what I'm asking here is based on wrong assumptions misunderstanding. I tried of my best to be clear, but that said, the subject is still novel to me. Vehicles In my game, I have vehicles that move autonomously. They are placed in a 3D space, and their motion is governed by a number of variables which are different for each vehicles. The one of interest here are primarily Only forward motion. A speed that can vary between min amp max, but whose min is not (even close to) zero. A steering radius that is dependent from the speed (the higher speed, the larger radius) Two maximum accelerations (for decreasing and increasing speed) Goal My goal is to implement some sort of AI that will a 100 accurate collision avoidance (i.e. I will be sure that the vehicles will never ever collide). Design Although I would prefer more the idea of having the AI "onboard" (i.e. each vehicle having it's own "collision avoidance AI", eventually querying and or sending messages to other vehicles) it is also possible for me to implement the CA AI at a central level (dispatching commands to the vehicles). In most of the cases, the vehicle will simply have to steer clear of each other in any direction, but under certain circumstances, they will have to avoid collision and going towards the same target What I found so far and where I got stuck Within the many many links I found in other questions on this very site, I found of particular use these ones Collision between pool balls Unalligned collision avoidance Queuing While these three links "opened my eyes" in many ways, it is not immediately clear to me how to use that information in my case. In particular article 2 only "tries" to prevent collision (but collisions do happens time to time). While article 3 needs to stop vehicles sometimes to prevent collisions. What I also noticed, is that the collision avoidance algorithms linked above use a "instant projection" of linear speed to check if something is on the way of the vehicle. I was wondering if this is enough in my case or if I had to project my position in a more realistic way (e.g. If I am 60 into a steering 90 to the right, I should calculate my position for the rest of the 30 of the curve, and then assuming linear motion). Finally, I am particularly afraid of deadlocks. In other words although the density of vehicles in the world will be fairly low, I am worried that given a certain numbers of vehicles converging towards the same point, once they will realise they are on a collision course, any evasive manoeuvres will be impossible as it would bring the vehicle on a collision path with some other ones. Question How can I reach my "goal"? An in depth explanation is of course very much appreciated, but links to external resources would also be of great help (I'm sure I'm not the first with this problem, but probably I used the wrong keywords to search the web?) Thank you in advance for your help! |
18 | Javascript canvas check if all recs on the screen overlap a new one So I know the AABB collision detection formula, however, this code does not work. Whenever I press space, a new square pops up. But this new square can spawn inside another, something that I do not want to happen. Here is a snippet of the code I think is going wrong var xTopsBotsYTopsBotsSquares Makes a randint() function. function randint(min, max) return Math.floor(Math.random() (max min 1)) min function checkForOccupiedAlready(left, top, right, bottom) if (xTopsBotsYTopsBotsSquares.length 0) return true for (var i 0 i lt xTopsBotsYTopsBotsSquares.length i ) var data xTopsBotsYTopsBotsSquares i if (data 0 lt right data 1 lt bottom data 2 gt left data 3 gt top) Do nothing else return false return true Makes a new square function makeNewsquare() var checkingIfRepeatCords true DO loop that checks if there is a repeat. do Makes the square x y positions var squareRandomXPos randint(50, canvas.width 50) var squareRandomYPos randint(50, canvas.height 50) Tests if that area is already occupied if (checkForOccupiedAlready(squareRandomXPos, squareRandomYPos, squareRandomXPos 50, squareRandomYPos 50) true) xTopsBotsYTopsBotsSquares.push( squareRandomXPos, squareRandomYPos, squareRandomXPos 50, squareRandomYPos 50 ) console.log(squareRandomXPos, squareRandomYPos, squareRandomXPos 50, squareRandomYPos 50) checkingIfRepeatCords false while (checkingIfRepeatCords true) |
18 | Collision with walls in a completely tile based game I am making a tile based game, in which also the player movement is completely snapped to the grid. Imagine sokoban. I basically have a 2d array for the layout of the level (walls not walls), and the player can check is there's a wall where he is going. My question is, when the player is trying to move into a wall, should I Let it move into the wall, then later check if it's in a wall and if needed revert it's movement? Check whether it is going to move into a wall and prevent it beforehand? I understand the answer may heavily depend on the structure of my code, but I'd still like to hear some opinions about how it was done in the past. What do you think? which of the two is better? (or is there a third option) |
18 | Area attack collision resolving I'm planning to write little 2D go right and swing your sword game. When i started to write my ideas on paper i've come across a little problem. Let's say i'm using magic spell, ex. fireball which technically is a signle projectile flying slowly in a specified direction. As it's defined to be a piercing projectile, I want it to hit every enemy only once, no matter how big their sprites are. And how I do it? I know i can use the array of already hit enemies and check every frame if projectile collides something new, but is it a correct way? Are there any tried and true ways of resolving problems like this? |
18 | Multiple collisions within a single frame cycle? So say you want to simulate several objects in two dimensions, just bouncing around in a finite space. Using AABB and sweep tests, it shouldn't be that complicated to calculate single collisions between objects. But if you want to have an object bounce off another surface in the same frame (one collision), how do you account for any additional collisions after that first one? This might not make much sense, so I put a little graphic together to explain what I mean. So say all this is happening in one frame cycle. The gray box moves up and bounces off the wall on the top that's easy enough. That orange box is the problem, though. How do I calculate that collision as well (where the two translucent boxes are)? OR, if the frame rate is high enough, does it even matter? Thanks! |
18 | Spatial Hashing is set up.. now how should I go about actual collision logic? So I have a spatial hashing system set up and it works. It puts players in buckets based on their x y width height So I was going to check collisions on each frame when I loop through the entity for updating their physics. But how would I go about duplicate collisions? Say I'm checking for player a, which is in the same bucket as bullet a.. I check if there's a collision and there is, should I do the collision logic right there? Or should I add the collision to a list and iterate through that list at the end of the frame to handle the logic for each collision? This way I can also apply logic to prevent duplicate collisions. Or should I just do all the logic right there and then when the initial collision is made? |
18 | Collision detection in multiplayer games This a followup to my previous question How to implement physics and AoE spells in an MMO game?. There, we concluded that all physics have to be done on the server, and that I should use cylinders for calculations. Now, how can I check for collision detection on a ground to player basis on the server? It's fairly easy if the ground is a flat space, I just check if the player's z coordinate is lower than some value and voila, but, what if the map ground itself is a model? How do I know where hills are on the server side? How do I know when object collisions happen? I'm using node.js and socket.io. |
18 | Allowing one sprite to move through another in Quintus I have a Bumper class extended from Sprite Q.Sprite.extend("Bumper", init function(p) this. super(p, gravity 0 ) this.add("2d, ... etc. I have an Enemy class that should trigger a function when the center of the Bumper and of the Enemy collide. I was thinking about doing something like this in my Enemy class this.on("bump.top, bump.bottom, bump.left, bump.right", function(collision) if(collision.obj.isA("Bumper")) if (this.p.x collision.obj.p.x amp amp this.p.y collision.obj.p.y) Do something ) But for that I need the two sprites to move through one another. Is there a way to do that while still checking for collision ? |
18 | What is the correct formula for penalty forces? I am trying to add penalty forces between two hard body objects, so when they collide they move in a realistic way. What I have so far is this var totalMass aMass bMass var temp (aMass totalMass aVelocity) (bMass totalMass bVelocity) newVelocityB (bMass totalMass bVelocity) (aMass totalMass aVelocity) newVelocityA temp Originally I thought this was correct and it seems to work for the most part. However, this doesn't seem to be flawless. For example, if the collided object is a vertical wall (represented with a mass of infinity), the wall's velocity of (0,0) will be the final result. So, for an object moving diagonally with a velocity of (10,10) and hitting the wall, will result in a velocity of (0,0). In my case I would expect that the y component of the velocity remains 10, and it keeps sliding up the wall. Can anyone tell me if I'm on the right path, and how I can modify my formula to make sure that the y velocity does not become 0? I have considered that the collision normal of the wall could be important (in this example 1, 0 ), or the perpendicular of the normal, however I still have not figured out how to apply it in this formula. Multiplying by the perpendicular of the normal was my first idea, but this isn't the correct answer. |
18 | How can I reproduce the physics that we can see in Dawn of Titans? I'm working on a hobby RTS project and I want to implement collision physics between soldiers like in the mobile game Dawn of Titans. Here is a video reference https youtu.be Fnpot2NeJl8?t 341 How can I achieve this? |
18 | 2D Rope Collision Detection I'm wanting to create a rope that can collide with objects like in the following youtube video 2D Game Physics Rope I'm thinking that you implement the verlet integration which uses points and connects these points with lines. I'm trying to figure out what type of collision detection you would apply to the rope to get the effect in the video. I'm thinking you would have to do some cd to each point. I would like to use box2D, so I'm wondering would making each point a rigid body work? Any advice would be appreciated. |
18 | Are there well known algorithms for fitting a polygon to an arbitrary shape? I'm using the Chipmunk physics engine to make the levels for a 2D C game. I'd like to be able to fit a polygon to an arbitrary shape to serve as the collision mask. Given a black and white collision mask for an arbitrary level object like this Are there any well known algorithms for getting this I could then use the red polygon to create a physics object to go with the image. |
18 | Pixel perfect collisions for platforms I'm trying to create pixel perfect collision detection but I don't know how to handle collisions when there is a jump. Here I have one image of a sample map But maybe I had a bad supposition assuming that all the pixels are little collision points. I mean , there is no differences between y axis collision and x axis collision in my collision map. I have been treating each axis collision split, but that is bad done when diagonal jump have been made, cause you'll get an error in x or in y while correcting the position. Then I thought that maybe I was wrong in my supposition that I didn't need to split for pixel collision type. I will resume it in 2 questions how can I handle pixel perfect collisions for a platformer? if I'm doing it well, How to manage the x axis, y axis problem? P.S My 'player' uses a box collider. |
18 | Delaying certain actions functions in libgdx using Timer? Hello I am trying to delay a part of the processes in my game, but it happend that I use one of my variables in an inner class so I have to make it final, but by making it final I can't assign new value when I find it. All I am asking for is to explain me how to do the delay without making my variable final. Here is my code public class TomatoScript implements IActorScript private CompositeActor tomato private static final int speed 100 private BitmapFont bFont private Batch bch ArrayList lt FruitScript gt fruits private final int dmg 10 private int hp 50 private Rectangle bounds private int state 0 private FruitScript collidetFruit private boolean dead() return hp lt 0 private void setHp(int dmg) hp hp dmg public TomatoScript(Batch b, BitmapFont bf, ArrayList lt FruitScript gt fruits) this.bch b this.bFont bf this.fruits fruits Override public void init(CompositeActor entity) this.tomato entity tomato.setPosition(200, 129) bounds new Rectangle(tomato.getX(), tomato.getY(), tomato.getWidth(), tomato.getHeight()) bch.begin() bFont.draw(bch, Integer.toString(hp), tomato.getX() 20, tomato.getY() 95) bch.end() Override public void act(float delta) switch (state) case 0 tomato.setX(tomato.getX() speed delta) bounds.setX(tomato.getX()) bch.begin() bFont.draw(bch, Integer.toString(hp), tomato.getX() 20, tomato.getY() 95) bch.end() if (tomato.getX() gt 1090) tomato.remove() if (collisionFound()) state break case 1 if (collisionAct(collidetFruit)) state 0 break private boolean collisionFound() for (FruitScript f fruits) if (f.getBounds().overlaps(bounds)) collidetFruit f return true return false private boolean collisionAct(FruitScript f) com.badlogic.gdx.utils.Timer.schedule(new com.badlogic.gdx.utils.Timer.Task() Override public void run() f.setCol(true) here it says I should make the "f" final. f.setHp(dmg) here also. setHp(f.getDmg()) ,2) if (f.dead()) fruits.remove(f) return true if (dead()) if (!f.dead()) f.setCol(false) tomato.getScripts().remove(this) tomato.remove() return false return false Override public void dispose() I've tried to make it final, but it ruins everything it's supposed to stop the actors do the damage taking and then the one alive to continue, but it was doing it too fast in a blink of an eye. When you make the f final, it can't get the new item it should collide with. I hope someone can help ) |
18 | What data should a generic collision detection system gather? I'm working on a relatively generic 2D AABB collision detection system for a game engine, and I've re written it more times than I'd like to admit, due to not calculating or recording specific details of each collision. Right now, this is what I'm collecting Collision time as a fraction of an update cycle in the game loop. Location of the collision. ID of the colliding object. Each object has a Set that holds this data for each collision (I'm working with a component entity system) so other systems can use the recorded data. The problem I just ran into was that I needed to know which side of the object the collision takes place on. What other values or points of interest should I calculate or record, per collision? What do you look for in a standard collision detection system? |
18 | Voxel traversal for parabolic projectile arc under constant gravity For linear polynomials, there's a bunch of algorithms for efficiently determining which voxels to test for collision (eg. A Fast Voxel Traversal Algorithm for Ray Tracing ). I'm having troubles though, searching for algorithms that work for any other case, such as a parabolic projectile arc under constant gravity. Are there any algorithms for that case, or am I stuck just trying to sample at a high enough frequency that only rarely will a projectile travel though a wall without getting detected. |
18 | Should I do intersection testing in world or object space? I'm adding basic ray casting and collision detection for my game, and also adding bounding volumes and collision meshes. The ray is cast in world space and each mesh's node can track its world transformation. Considering I want to test for intersection between a ray and bounding volume and also bounding volume with other bounding volume, in what space should I perform the intersection test? Scenarios that I have in mind Transform ray into object's local space, perform test, then inverse transform the resulted point. Transform bounding volume into world space and perform it there, or should I always keep bounding volumes in world space? Perform bounding bounding test in world space or one of the objects? Do things change much between static and dynamic collision regarding used spaces? |
18 | What algorithms exist for generating collision geometry from an image? I am currently working on a game using SFML and Box2D. I am interested in generating collision geometry from the sprite data that I load into SFML. So, for example, an algorithm that would do this would take an image and find the edges (for example where the alpha area starts) and then generating a polygon that fits to those edges. Can I be pointed to any resources that describe an algorithm to do this? |
18 | Rotated Sprites collision detection I am trying to implement checkCollision function in my game, I used AABB method but the problem is that my sprites are rotated so it's not really precise. I could finely describe my Sprites with rotated ellipses. Is there any more precise way of detecting the collision if I have the following attributes of entities entity.x entity.y entity.width entity.height entity.angle Here is what I have coded so far (x and y are in the middle of my sprite) this.checkCollision function(entity1, entity2) return (entity1.x (entity1.width this.COLLISION EPSILON WIDTH) 2 lt entity2.x (entity2.width this.COLLISION EPSILON WIDTH) 2 amp amp entity1.x (entity1.width this.COLLISION EPSILON WIDTH) 2 gt entity2.x (entity2.width this.COLLISION EPSILON WIDTH) 2 amp amp entity1.y (entity1.height this.COLLISION EPSILON HEIGHT) 2 lt entity2.y (entity2.height this.COLLISION EPSILON HEIGHT) 2 amp amp (entity1.height this.COLLISION EPSILON HEIGHT) 2 entity1.y gt entity2.y (entity2.height this.COLLISION EPSILON HEIGHT) 2) PS my cousin told me to do it with three circles (which creates a shape very similar to the ellipse) but I do not really know how to do it. |
18 | Have the character automatically slide around obstacle corners Like this The player is only holding right, however the character still moves up a bit to go around an obstacle. My current collision system has access to The entity's previous position The entity's current position The entity's (axis aligned) bounding box All the obstacles and their (also axis aligned) bounding boxes Also it proccesses each axis separatelly. How can I implement this? |
18 | Problems about oriented bounding boxes collision detection I get a question for the following code which detects if two OOBs collide by SAT. The OBBs struct is also listed below. struct OBB Point c OBB center point Vector u 3 Local x , y , and z axes Vector e Positive halfwidth extents of OBB along each axis int TestOBBOBB(OBB amp a, OBB amp b) float ra, rb Matrix33 R, AbsR Compute rotation matrix expressing b in a s coordinate frame for(inti 0 i lt 3 i ) for(intj 0 j lt 3 j ) R i j Dot(a.u i , b.u j ) Compute translation vector t Vector t b.c a.c Bring translation into a s coordinate frame t Vector(Dot(t, a.u 0 ), Dot(t, a.u 2 ), Dot(t, a.u 2 )) Compute common subexpressions. Add in an epsilon term to counteract arithmetic errors when two edges are parallel and their cross product is (near) null (see text for details) for(inti 0 i lt 3 i ) for(intj 0 j lt 3 j ) AbsR i j Abs(R i j ) EPSILON Test axes L A0,L A1,L A2 for(inti 0 i lt 3 i ) ra a.e i rb b.e 0 AbsR i 0 b.e 1 AbsR i 1 b.e 2 AbsR i 2 if (Abs(t i ) gt ra rb) return 0 Test axes L B0,L B1,L B2 for(inti 0 i lt 3 i ) ra a.e 0 AbsR 0 i a.e 1 AbsR 1 i a.e 2 AbsR 2 i rb b.e i if (Abs(t 0 R 0 i t 1 R 1 i t 2 R 2 i ) gt ra rb) return 0 Test axis L A0xB0 ra a.e 1 AbsR 2 0 a.e 2 AbsR 1 0 rb b.e 1 AbsR 0 2 b.e 2 AbsR 0 1 if (Abs(t 2 R 1 0 t 1 R 2 0 ) gt ra rb) return 0 reset code are omitted For the part "Test axes L A0,L A1,L A2", why do we multiply each b.e i by the component from each axis in a's coordinate frame then add the result together? I know this part want to project the half positive extents onto each axis in a's coordinate frame, but it should do the dot product with the b.e vector and the projected axis, am I wrong? (that is b.e 0 AbsR 0 i b.e 1 AbsR 1 i b.e 2 AbsR 2 i ) For the part "Test axes L B0,L B1,L B2", It seems a.e vector is multiplied by each axis in a's coordinate frame, why don't transform the a.e vector into the b's coordinate frame since they are not at the same coordinate frame? For the part "Test axis L A0xB0", Why can we get ra and rb values by that arithmetic operation? What does Abs(t 2 R 1 0 t 1 R 2 0 mean? |
18 | How to store 3D entity position, offset, and transformation data for parent and children? I am looking for a cleaner pattern to storing character position data, offsets, and transformations. I currently have a character with a vec3 for position. Entity position vec3 rotation vec4Quaternion velocity vec3 I use this position vector as the world coordinate. So that when Y 0 I imagine the characters feet are on the ground. This makes it easier to think about where the entity is in world space. The problem I am having is that mesh entities like colliders or the skin mesh will assume a position vector at the center of the mesh. This is causing me to have to do a bunch of transformation juggling. I can't 1 to 1 map these meshes to the entities world position. I will update my characters 'ground position' when they move. then have to calculate the new 'center position' which is calculated like centerPosition groundPosition.x groundPosition.y entityHeight 2, groundPosition.z I"m wondering if there is a better pattern for this. Maybe I assume the entities position vector is a 'center position' as well? but not clear to me how to handle the ground offset in that case. |
18 | How to handle objects at the edges of spatial partition cells? A lot of games store object positions as floats and have a closed ball for the game area (eg. a rectangle and objects are allowed to have position coordinates on all 4 edges). However, this becomes problematic when partitioning the game area (eg. gridding quadtrees). The edge cases would have to be added in so that 2 edges of the game area are included in rectangles that touch them or objects on 2 edges would have to be missed out in the partition. Is there another solution to this or do games (and other programs this applies to) usually go with one of the above 2? (One solution is to use integer coordinates, but what if using floats is unavoidable?) |
18 | Bringing islands close together programmatically I generate island continent maps and I want to make a grand archipelago of sorts where all these islands are located. The problem is that I don't know a smart way to place the islands programmatically so that the keep a minimum distance from each other. Sure, I can create a quadtree but then how do I place it? Placing it on top of another island and move it away in a random direction? I'm attaching a photo of what I want to do, easily done in Paint .NET from 6 individual maps. The scale I'm talking about would be placing about 3 10 continents, each with a resolution of 4Kx4K upwards. (I'll only allow reflections and translations in placement, to preserve some 4 8 connectivity pixel work that I've done for the maps) What I'm NOT looking for a global minimum solution ( all islands as close together as possible) using a heavyweight physics maths library or tons of code a super simplistic solution either (e.g. calculate OBBs and use those to resolve collisions) |
18 | Python Pygame Collision problems I'm currently developing a game in Python Pygame and i came up with a problem with the player and the platforms. The game is a 'runner' where the player it's fixed (The 'x' position isn't variable, only the jump). This is how i'm currently doing the collisions managment def collide(self, yvel, platforms) for p in platforms if pygame.sprite.collide rect(self, p) if yvel gt 0 self.rect.bottom p.rect.top self.onGround True self.yvel 0 if yvel lt 0 self.rect.top p.rect.bottom 'platforms' its a RenderUpdate group with the platforms (a simple sprite). When the player is falling from a platform and collides with the next platform, not exactly on top of it but a little below, that's when the character jumps to the position shown in the code above, rather than collide and fall. I don't know how to check the left bound without a 'xvel' parameter. (The screen shows an example, but the player only changes the y axis coordinates, the platforms are updating their position) I've tried supply a number to a 'xvel' parameter, and check if the character wasn't on the ground (Jumping) and the 'xvel' was greater than 0, but it isn't working at all. Thanks in advance. |
18 | JavaScript 2D Top down Collision Detection issue I'm developing a 2D Top down Game using HTML5 Canvas and a custom Game Engine. I'm implementing the Quad intersection detection (Function below, if it helps) on different areas of the Sprites (As they're larger than Tiles in some cases), and have thought of an issue with this. I want to check these areas before moving, using the amount of pixels I will move if allowed to (Nothing blocking the character). Below if the code I use to move the Player move function(delta) var distance Math.floor(this.getSpeed() Math.floor(delta 10)) this.setMoving(false) if(Engine.input().isPressed(Engine.keys.LEFT ARROW)) this. config.x distance this.setMoving(true) this.setDir(0) if(Engine.input().isPressed(Engine.keys.RIGHT ARROW)) this. config.x distance this.setMoving(true) this.setDir(1) if(Engine.input().isPressed(Engine.keys.UP ARROW)) this. config.y distance this.setMoving(true) this.setDir(2) if(Engine.input().isPressed(Engine.keys.DOWN ARROW)) this. config.y distance this.setMoving(true) this.setDir(3) this.boundaries() As the distance is not 1 pixel, it will be checking a few pixels ahead of the Player for solid tiles, and if there is one X many pixels in front of them, they can't move the distance and stop. Problem So let's say the distance is 3. If they're 2 pixels from a Solid Tile, they will not move those 2 pixels because of the collision detection, meaning there will be a 2 pixel gap between the Player and the tile, which will only increase the larger the Player, or Entities, speed. Is there any way to get around this, other than having to check pixel by pixel for each anchor point I want to check collision on? Collision Detection collided function(box1, box2) Basic Quad intersection Collision return ( ( (box1.x gt box2.x amp amp box1.x lt (box2.x box2.width) ) ( (box1.x box1.width) gt box2.x amp amp (box1.x box1.width) lt (box2.x box2.width) ) ) amp amp ( (box1.y gt box2.y amp amp box1.y lt (box2.y box2.height) ) ( (box1.y h1) gt box2.y amp amp (box1.y h1) lt (box2.y box2.height) ) ) ) ? true false , |
18 | Collision detection, stop gravity I just started using Gamemaker Studio and so far it seems fairly intuitive. However, I set a room to "Room is Physics World" and set gravity to 10. I then enabled physics on my player object and created a block object to match a platform on my background sprite. I set up a Collision Detection event for the player and the block objects that sets the gravity to 0 (and even sets the vspeed to 0). I also put a notification in the collision event and I don't get that either. I have my key down and key up events working well, moving the player left and right and changing the sprites appropriately, so I think I understand the event system. I must just be missing something simple with the physics. I've tried making both and neither of the objects "solid". Pretty frustrating since it looks so easy. The player starting point is directly above the block object in the grid and the player does fall through the block. I even made the block sprite solid red so I could see it (initially it was invisible, obviously). |
18 | Is it possible to have concurrent collision detection where every entity acts at exactly the same time? There are many algorithms that can be used for collision detection. In many cases we check for an overlap in coordinates of an entity. If we make a triangle a,b and c. We have 2 entities at a and b heading for a collision at c but each of them are moving at exactly the same time, what kind of algorithm could work? It seems more like a chess game where you would have to predict every move that the other entity would have to make, if they swerve to the left to avoid a collision will they also run the chance to collide. Is it possible or is it too complex? Would it work for thousands and millions of entities in the same search space? |
18 | 3D collision physics. Response when hitting wall, floor or roof I am having problem with the most basic physic response when the player collide with static wall, floor or roof. I have a simple 3D maze, true means solid while false means air bool bMap 100 100 100 The player is a sphere. I have keys for moving x , x , y , y and diagonal at speed 0.1f (0.1 ftime). The player can also jump. And there is gravity pulling the player down. Relative movement is saved in relx, rely and relz. One solid cube on the map is exactly 1.0f width, height and depth. The problem I have is to adjust the player position when colliding with solids, I don't want it to bounce or anything like that, just stop. But if moving diagonal left up and hitting solid up, the player should continue moving left, sliding along the wall. Before moving the player I save the old player position oxpos xpos oypos ypos ozpos zpos vec3 direction direction vec3(relx, rely, relz) xpos direction.x ftime ypos direction.y ftime zpos direction.z ftime gx floor(xpos 0.25) gy floor(ypos 0.25) gz floor(zpos 0.25) if (bMap gx gy gz true) vec3 normal vec3(0.0, 0.0, 1.0) lt Problem. vec3 invNormal vec3( normal.x, normal.y, normal.z) length(direction normal) vec3 wallDir direction invNormal xpos oxpos wallDir.x ypos oypos wallDir.y zpos ozpos wallDir.z The problem with my version is that I do not know how to chose the correct normal for the cube side. I only have the bool array to look at, nothing else. One theory I have is to use old values of gx, gy and gz, but I do not know have to use them to calculate the correct cube side normal. |
18 | LWJGL Collision Detection I cannot find LWJGL collision detection with a camera and walls. Like making it to where you can not walk through walls and other different shaped rectangular prisms and cubes. How do I set up LWJGL collision? |
18 | How to build bullet (hit) damage detection in Augmented Reality to a real life person acting as an opponent? I am building an Android AR game using ARcore 1.18 in Unity 2019.4.5f1 (LTS). Now I want to create something like bullet damage detection just like it is built in a normal Unity 3D game. Of course, the biggest problem is how can I even detect the real person's hitbox like it is done in a normal game? I need to somehow be able to attach the bullet damage script to the body of the real life person in real time. Has anyone tried this before? How can we achieve this? I understand if I might not get a spoonfed tutorial but some help towards what should I be doing to achieve this will be greatly appreciated. I see some other FPS Augmented Reality games which either uses Laser Tag (Father.io) or Barcodes to scan the opponents. These are definitely some great ideas to create an FPS game experience but still, if possible, I want to try it with just the mobile camera without any external support. I am ready to bear some accuracy loss ) |
18 | LibGDX obstacle collision How can I handle collisions with obstacles in LibGDX? Is there any automatic way to stop the character's movement when it collides with a wall or I have to constantly poll for all the possible objects it might encounter and stop the movement accordingly? Polling this way seems pretty poor performance wise, especially if the framework already does that for me and I make no use of it. My game is a top view roguelike, more or less like "The Binding of Isaac". EDIT some beginners like me might make good use of it. Since LibGDX has no built in collision detection without Box2D, for games where physic calculation is not needed you can build your system as follows Create 3 lists (Static, Dynamic, Controlled) where you put all your (relatively inherited) objects in the scene. Static objects (walls, obstacles, traps) are passive and perform no checks. Dynamic objects (projectiles) perform checks on both Static (stop if you hit a wall, destroy self) and Controlled (deal damage) Controlled (players, enemies) objects perform checks on self (player hit AI controlled enemy) and static objects After a collision is reported notify the relative objects. Controlled objects can be Dynamic aswell but if you have a lot of projectiles flying around you can avoid self checking Dynamics and improve the performance. This way you should reduce a lot of useless checks aswell as limit cross checks (both player and projectile notifying eachother) and keep your game well organized. This is just an idea that i'm testing now, I can't guarantee it's the best P |
18 | how get collision callback of two specific objects using bullet physics? I have got problem implementing collision callback into my project. I would like to have detection between two specific objects. I have got normall collision but I want one object to stop or change color or whatever when colides with another. I wrote code from bullet wiki int numManifolds dynamicsWorld gt getDispatcher() gt getNumManifolds() for (int i 0 i lt numManifolds i ) btPersistentManifold contactManifold dynamicsWorld gt getDispatcher() gt getManifoldByIndexInternal(i) btCollisionObject obA static cast lt btCollisionObject gt (contactManifold gt getBody0()) btCollisionObject obB static cast lt btCollisionObject gt (contactManifold gt getBody1()) int numContacts contactManifold gt getNumContacts() for (int j 0 j lt numContacts j ) btManifoldPoint amp pt contactManifold gt getContactPoint(j) if (pt.getDistance() lt 0.f) const btVector3 amp ptA pt.getPositionWorldOnA() const btVector3 amp ptB pt.getPositionWorldOnB() const btVector3 amp normalOnB pt.m normalWorldOnB bool x (ContactProcessedCallback)(pt,fallRigidBody,earthRigidBody) if(x) printf("collision n") where fallRigidBody is a dynamic body a sphere and earthRigiBody is static body StaticPlaneShape and sphere isn't touching earthRigidBody all the time. I have got also other objects that are colliding with sphere and it works fine. But the program detects collision all the time. It doesn't matter if the objects are or aren't colliding. I have also added after declarations of rigid body earthRigidBody gt setCollisionFlags(earthRigidBody gt getCollisionFlags() btCollisionObject CF CUSTOM MATERIAL CALLBACK) fallRigidBody gt setCollisionFlags(fallRigidBody gt getCollisionFlags() btCollisionObject CF CUSTOM MATERIAL CALLBACK) So can someone tell me what I am doing wrong? Maybe it is something simple? |
18 | How to create walls and rooms with Pixi I'm a JS dev but pretty new to Pixi and 2D developemnt so please bear with me as I explain this. I want to write a simulator for short path finding (for evacuation purposes). I decided to use Pixi.js for this since it seems capable of doing everything I need to do. I followed this tutorial to try to learn how Pixi works and if its right for this. The tutorial didn't seem to answer many questions I have and I still have some confusion. Before I dive into writing the code, I want to know how wall detection in Pixi acheived. Take the below map for example It is a 800 x 800 png file (where everything but the blue is transparent no grid lines ) that i can load into Pixi as a Sprite. I created it in Tiled editor. So it can be exported as a tilemap, JSON, CSV etc. When I export it as JSON, here is the file contents https pastebin.com zGh1XmR7 The blue boxes represent walls. I want to load in other various sprite objects so that it will look like this The people in the simulations cannot cross the blue walls and they cannot cross the pink circles (they represent danger zones). I intend to use easystar.js to find the shortest path to exits for the people sprites in the map. So my question is this, how does Pixi recognise the blue walls? Is it something I have to do when creating the tileset png? Like something defined in the JSON file for the tileset atlas? Maybe SVG? Or is there a pixi function to do this? Is this the best approach to doing this and is Pixi even the best way to do this? I'm looking for a tried and tested solution or a pointer in the right direction. |
18 | Best Efficient way to implement a 3d Collision I've already programmed a 2d based collision system for a previous game. It was my first collision system and it was ugly. I was looking for collision between objects by checking all objects with all objects. I've already heard about a grid system with cells where an object will only look the collision with other objects from its current cell(s). Is it really a good way to check collision? I'd like to have a good technique to loop trough all my items in a 3d world. |
18 | Finding collision point of moving projectile bullet with a cube I am programming a game in the spirit of Wolfenstein 3D (2D grid map, 1 cell 1 cube) and I wanted to implement shootings. I didn't want the shootings to happen in one frame so, I wanted to see the beams flying everywhere. So this gets a bit complicated for me to test for impacts. To be fair, I'm not really sure how I'm supposed This is how I used to do it I took the position of the beam and checked on the map to see if there is a wall at said position. It works great when the beam is moving very slowly. But when they go extremely fast, naturally, as you would expect, they clip through walls. Here you can have an idea of what I'm looking for. 2D grid with white cells being air and grey cells being walls. Player is green, beam is red and dotted lines represent the beam on next frames. And orange is the collision So I'm not exactly sure when and what to test for collisions here, as well as how to find the impact's position. What would be the most optimised way to test for collisions ? |
18 | How do I compute the point of a triangle ray intersection? I have a line (the direction vector of the player) and a triangle representing the face of a model (so composed of 3 points). I can't find the mathematical operation to check if that vector is intersecting with this triangle, and how far from the player... |
18 | Collision for mobile game I'm writing a little game in as3 using Starling, and I need to check collision between 2 boats that can rotate. I don't need the pixel perfect collision, but bounds collision is not enough too. The boat look more or less like this I was thinking about create one square on the back of the boat and a triangle on the front, than for each boat, check if the square collide with the other boat square or triangle, and the same for the triangle. I just don't know how to do that, I don't know if it's possible with the Shape.hitTest, or if it's the best way to do that. What can I do? |
18 | How to resolve collision when both of the intersecting bodies were moving? Suppose there are two quadrilaterals A and B. A is stationary but B is moving. They collided. Now B is inside A. To check if they are intersecting I can use 2d separating axis theorem (SAT). To push B out of A so that they are not intersecting anymore, I can again use SAT to get the Minimum Translation Vector(MTV) and project B out of A using it. My problem is, what should I do when both A and B were moving, and then they collided? I can't project A out of B or B out of A alone since both of them were moving. How should I separate them? |
18 | Unity3D collider performances on mobile iOS devices I'm experimenting with Unity3D and colliders. Unfortunately I still don't have Unity Pro version and I can't use the profiler. Consider the following situation mobile devices (ios, iphone 3GS). an infinite runner game (consider something like agent dash or temple run). The player run along its path collecting bonuses and possibly hurting obstacles. the number of objects along player's path is very high. The first simple approach is to use a rigidbody with a collider attached to the player (let's say it could be even a shere collider) and use a collider for each object in the scene (coins, obstacles, bonuses,...) . AFAIK, using hundreds of colliders could have a serious impact on performances,specially on mobile devices, am I right? So here's some questions In the situation described above, is that feasible use collider to detect objects collectable by a player running along a path? Could be a better idea to store the location of the collectables objects inside some kind of data structure and completely avoid to use Unity collision detection? What's a reasonable average number of RigidBody Sphere Collider that can be used in a single scene on a mobile device? Does anyone has implemented something similar? Could you suggest me the right way to go? |
18 | Retreive 3d World Map coordinates from touch click input with LIBGDX? Problem I am trying to create an RTS style interaction. I want to be able to click on the map and have characters move to the click location. I haven't been able to figure this out, even after reveiwing tutorials from the one and only xoppa and several other's inqueries on the same concept. Other's seem to be happy utilizing collision with a near or far plane or a basic collision shape. However, I have a map with variations in height. I can't tell if I'm not creating my complex collision shape correctly or I'm just making things more complicated than need be. The code I think is relevelvant is as follows. A model is loaded from a G3DB scene in the exact same manner of xoppa loading a 3d scene tutorial. After loading, I call the following method in my ModelInstance class. private Array lt Mesh gt modMesh new Array lt gt () public void createShape() modMesh model.meshes When a user clicks the mouse or taps the touch screen, I call this method to check collision of the ray from the camera to presumably the part of the map we were trying to touch. public Vector3 checkSelection(Ray ray) Vector3 intersection new Vector3() for(int i 0 i lt modMesh.size i ) mesh modMesh.get(i) float v new float mesh.getNumIndices() mesh.getNumVertices() mesh.getVertexSize() short ind new short (mesh.getNumIndices() 6 6) (mesh.getNumVertices() 1) Intersector.intersectRayTriangles(ray, mesh.getVertices(v), ind, mesh.getVertexSize(), intersection) return intersection So, when I run this code, it returns Vector3 values. They seem to be off though. For instance, my camera is looking at point (0,0,0). If I click where (0,0,0) appears on the screen, it will return a value like ( 14.56, 18, 85). I imagine I am not creating a proper collision shape for the map. Which again leads to my question. How do I obtain the collision coordinate on a 3D map with variations in height in LibGDX? Side Note My intersecting collisions with normal collision shapes work perfectly. This is the reason I'm assuming I am completely wrong in the way I create a collision shape for the map itself. Thank you in advance for any input and assistance offered. |
18 | What are the advantages and disadvantages of overlap testing and intersection testing? I have been looking for the advantages and disadvantages of both overlap testing and intersection testing, but I was only able to find a few disadvantages overlap testing may fail for objects moving very fast, and intersection testing makes assumptions that may lead to wrong predictions, such as a constant speed and zero accelerations. What are the advantages and disadvantages of overlap testing and intersection testing? |
18 | Circle inside ellipse collision intersection (preventing circle from leaving the ellipse) I am working on a 2D RPG with a turned based battle system. Characters move inside the confines of an ellipse movement area and when they leave the boundaries will be pushed back inside. (i.e they should be able to walk around the inner part of the ellipse). Previously we were using circles for the movement area and I wrote the code to do circle inside circle collision (not too difficult because the radius is always the same) but since we will change to using an ellipse, I am trying to update the code. I have looked at a few solutions for actual ellipse collision intersection and the math looks..daunting. My questions are Are there any clean solutions to doing circle inside ellipse collision intersection? Should I be approximating the ellipse collision in another way? Like using an n sided polygon? I am a bit lost on how to approach this and could really use some advice. |
18 | Box collisions between vehicles in traffic pattern I'm working on a traffic simulator. Right now, I have ways to manage 4 way stop intersections and a solution for efficiently determining which vehicles are colliding with one another. All vehicles operate independently of each other and will overlap ignore any vehicles they pass. I'm looking to build a way to resolve collisions between vehicles such that a Vehicle will follow the Vehicle in front of it. If a Vehicle stops at an intersection, any Vehicles that follow thereafter should stop and wait as well. Below are the relevant components I already implemented TileGrid containing road segments. TravelGraph graph of waypoints for Vehicles to travel along the TileGrid. CollisionTracker for efficiently determining which vehicles are colliding, i.e. O(1) lookup for get collisions( lt vehicle id gt ) gt List lt vehicle ids gt Intersection for determining which vehicles are waiting at an intersection and determining which Vehicles may pass through it. The only seemingly viable algorithm right now is Calculate velocities and position of all vehicles after tick Determine which vehicles are in a collision Determine which vehicles are in a "collision group" (e.g. if A collides with B, collides with C, then (A, B, C) are in a group) Determine the order of the vehicles in each group based on their velocities (e.g. if A, B, and C are moving to the right and C is the rightmost, followed by B, followed by A, then the order is C, B, A ). Recalculate the positions of all vehicles, in order from front to back (e.g. C, B, A) such that they reside adjacent to, but not touching the Vehicle in front of them. Problems with this solution This requires a lot of recalculations. If there's a line of n vehicles waiting on a light, I'd effectively compute 2 n positions per tick in addition to all other overhead for establishing groups, order, etc. If the vehicles are following each other around a turn, the logic for finding the "vehicle order" becomes more complex, adding on to the computations per tick. Ideally moving the vehicles would require n calculations per tick. I'm open to any all suggestions here. I've tried building my code as modular as possible, so I'll happily rewrite large parts of it if there's a better architecture to solve this problem. Below is the visual representation of the TileGrid (black), TileGraph (purple), and Vehicles (circles). |
18 | Having issues with pong physics, is my approach wrong? I've been working on a pong clone, i've made games in the past but they have all been very hacky. This time I was trying to go for a better approach in terms of using OOP or patterns. So far the games not posed many issues, I am however having problems thinking about the collision system and ball physics. In my main loop the collision code is as follows if (ball gt Y lt 0) ball gt direction ball gt direction if (ball gt ballSpeed lt 700) ball gt ballSpeed 25 if ((ball gt X ball gt width gt player2 gt X) amp amp (ball gt X ball gt velocityX) (ball gt width) lt player2 gt X player2 gt width amp amp (ball gt Y ball gt velocityY) (ball gt height) gt player2 gt Y amp amp (ball gt Y ball gt velocityY) (ball gt height) lt player2 gt Y player2 gt height) ball gt direction 70 if (ball gt ballSpeed lt 700) ball gt ballSpeed 25 if ((ball gt X ball gt width) gt player1 gt X amp amp (ball gt X ball gt velocityX) (ball gt width) lt player1 gt X player1 gt width amp amp (ball gt Y ball gt velocityY) (ball gt height) gt player1 gt Y amp amp (ball gt Y ball gt velocityY) (ball gt height) lt player1 gt Y player1 gt height) ball gt direction 70 if (ball gt ballSpeed lt 700) ball gt ballSpeed 25 The program checks the points of the objects rect's to see if they have passed any of the paddles and then applies changes to the balls public variables. Here is the ball update code if(move) velocityX int(cos((direction 0.0) M PI 180.0) (ballSpeed deltaTime)) velocityY int(sin((direction 0.0) M PI 180.0) (ballSpeed deltaTime)) rect.x velocityX rect.y velocityY X rect.x Y rect.y width rect.w height rect.h This PARTIALLY works however the ball goes in weird directions sometimes, on top of that the ball can actually go through the bottom portion of the paddle (it seems that from the bottom of the paddle, there is a gap the ball can exactly fit through). Really the physics of the ball just seem weird and not fluid at all. I'm not brilliant at maths so I don't really know of any other way to go about this. Help would be greatly appreciated. |
18 | Collision detection circle segment segment I've already implemented collision detection in my game loosely following this tutorial, which works great, but I realized there's one major flaw. The player and the enemies are circles, while the obstacles can be either segments or polygons or circles. Now, let's say I have segment A from point (100, 100) to point (300, 100) and segment B from point (100, 200) to point (300, 100), which means they form an acute angle, and player has it center in point (100, 125), with a radius of 25. If player starts moving right, it will eventually collide against segment B. My method checkCollisions() will return a vector, but if I apply that vector on player, it will be moved up and left, and will overlap segment A. If I call checkCollisions() a second time, player will be pushed down and collide again with segment B, so recursive invocations aren't a solution. Any ideas? Here's a picture to explain The g n vector direction is along the bisector of the two little vectors, but how do I find the length? |
18 | How can I implement rectangle collision response? I am working on a game in JavaScript and my current implementation of collision uses the shortest distance to push the intersecting object away, which isn't always correct. I've made this diagram of the ideal collision. The red box represents the starting position, the green box represents the proper position and the black box represents the static object it is colliding against. The blue arrow is the velocity vector. With my current implementation, the object would be placed in its final position and pushed out (and in this case it would be pushed left) How can I fix this? |
18 | Can Bullet Physics (or another 3d physics engine) use callbacks in my engine to check static geometry? I'm wondering if it's possible to use or hack Bullet 3d Physics (or another free 3D physics engine) so that I don't need to "import" my static geometry into Bullet instead I want to do it the other way, so Bullet uses some sort of callback system to check geometry properties of my mesh polygons. Sort of like that Bullet would expect a method in my static geometry classes "checkRayIntersection" or similar, and I take care of the details and optimizations myself. The meshes are immovable, so the only thing that I expect Bullet to care about is intersections and their normals, but I might be missing something.. EDIT as an example, consider a 10 million polygon terrain mesh which is changing all the time. You probably don't want to keep parallel data structures in the render engine and in the physics engine for this. You don't want to use an approximation for the physics either. Bullet uses something called MotionStates to solve this problem for its output I was hoping there was a similar design pattern for passing geometry input. |
18 | Can GJK be used with the same "direction finding method" every time? In my deliberations on GJK (after watching http mollyrocket.com 849) I came up with the idea that it ins not neccessary to use different methods for getting the new direction in the doSimplex function. E.g. if the point A is closest to the origin, the video author uses the negative position vector AO as the direction in which the next point is searched. If an edge (with A as an endpoint) is closest, he creates a normal vector to this edge, lying in the plane the edge and AO form. If a face is the feature closest to the origin, he uses even another method (which I can't recite from memory right now) However, while thinking about the implementation of GJK in my current came, I noticed that the negative direction vector of the newest simplex point would always make a good direction vector. Of course, the next vertex found by the support function could form a simplex that less likely encases the origin, but I assume it would still work. Since I'm currently experiencing problems with my (yet unfinished) implementation, I wanted to ask whether this method of forming the direction vector is usable or not. |
18 | Ground hitting system I want to know how to make character hit ground and lose health. For example when character is falling of one meter he losing only a small part of his health, and when he's falling of 10 metters he dying. I just want to know if it's about speed or distance or maybe even time? (If you can implement some code. please.) P.S. I'm planning to use SFML and C . |
18 | Collision in PyGame for spinning rectangular object.touching circles I'm creating a variation of Pong. One of the differences is that I use a rectangular structure as the object which is being bounced around, and I use circles as paddles. So far, all the collision handling I've worked with was using simple math (I wasn't using the collision "feature" in PyGame). The game is contained within a 2 dimensional continuous space. The idea is that the rectangular structure will spin at different speed depending on how far from the center you touch it with the circle. Also, any extremity of the rectangular structure should be able to touch any extremity of the circle. So I need to keep track of where it has been touched on both the circle and the rectangle to figure out the direction it will be bounced to. I intend to have basically 8 possible directions (Up, down, left, right and the half points between each one of those). I can work out the calculation of how the objected will be dislocated once I get the direction it will be dislocated to based on where it has been touch. I also need to keep track of where it has been touched to decide if the rectangular structure will spin clockwise or counter clockwise after it collided. Before I started coding, I read the resources available at the PyGame website on the collision class they have (And its respective functions). I tried to work out the logic of what I was trying to achieve based on those resources and how the game will function. The only thing I could figure out that I could do was to make each one of these objects as a group of rectangular objects, and depending on which rectangle was touched the other would behave accordingly and give the illusion it is a single object. However, not only I don't know if this will work, but I also don't know if it is gonna look convincing based on how PyGame redraws the objects. Is there a way I can use PyGame to handle these collision detections by still having a single object? Can I figure out the point of collision on both objects using functions within PyGame precisely enough to achieve what I'm looking for? P.s I hope the question was specific and clear enough. I apologize if there were any grammar mistakes, English is not my native language. |
18 | What is the meaning of this line algorithm? I have been looking at codes of several open source 2d games and I have found this function. GetLineCollisionHit(Vector2 Position1, int Width1, int Height1, Vector2 Position2, int Width2, int Height2) int tile1X Position1.X Width1 16.0) int tile1Y Position1.Y Height1 16.0) int tile2X Position2.X Width2 16.0) int tile2Y Position2.Y Height2 16.0) do int dx Math.Abs(tile1X tile2X) int dy Math.Abs(tile1Y tile2Y) if (tile1X tile2X amp amp tile2Y tile1Y) return true if (dx gt dy) if (tile1X lt tile2X) tile1X else tile1X (check collision) else if (tile1Y lt tile2Y) tile1Y else tile1Y (return true if collision) while (true) return false What is really checking is if there is any collision of solid tiles between two points, for this look for the line between the two tiles. But I do not know if it is a coding problem since it is not implementing neither Bresenham's line algorithm nor DDA or similar. So what are you trying to find in this line dx dy? What sense does it have to advance x while x y since that way a line is not correctly created. |
18 | Penetration Depth into a Planar Polygon I'm working on a self made physics engine, and I'm wondering about the best way to calculate the penetration depth into a polygon that lies in a plane given that resolution must occur along the polygon's normal. My current system correctly uses GJK EPA to detect if a polygon that lies in a plane is intersecting a 3D collider. However, in a case such as the one illustrated below, EPA would not calculate the separating axis to be along the plane normal, but rather outwards parallel to the plane, as that is the direction of minimum penetration. My first thought was to simply manually alter the resolution direction. After GJK detects a collision, I can calculate the support mapping of the polygon in the opposite direction of the plane's normal, then take its perpendicular distance from the plane as its penetration depth. However, in a case such as the one below, this would yield an incorrect penetration depth, as the support point does not project onto the plane. What's the best way to go about getting the penetration depth into the polygon, but only considering penetration of points on the polygon that actually project onto the polygon? |
18 | Deactivate keyboard input on collision I'm creating an online canvas game with a tank as player object. Now I have several structures in my canvas, that shouldn't be able to be overdriven by the tank... My solution is to detect the collision like that if(hero.x gt reactor i 'x' 32 amp amp hero.x lt reactor i 'x' 32 amp amp hero.y gt reactor i 'y' 32 amp amp hero.y lt reactor i 'y' ) collidetop true if(hero.x gt reactor i 'x' 32 amp amp hero.x lt reactor i 'x' 32 amp amp hero.y gt reactor i 'y' amp amp hero.y lt reactor i 'y' 32) collidebottom true if(hero.x gt reactor i 'x' 32 amp amp hero.x lt reactor i 'x' amp amp hero.y gt reactor i 'y' 32 amp amp hero.y lt reactor i 'y' 32) collideleft true if(hero.x gt reactor i 'x' amp amp hero.x lt reactor i 'x' 32 amp amp hero.y gt reactor i 'y' 32 amp amp hero.y lt reactor i 'y' 32) collideright true The hero object is the tank, hero.x the x coordinate, and so on... Now I'd like to deactivate the keyboard input for the direction key, if the objects collide... For this reason I have the variables wok, aok, sok and dok they all contain booleans. If wok false, then the key "w" is deactivated... I've connected the collide variables to the keyboard inputs if(collidetop true) sok false if(collidetop false) sok true if(collidebottom true) wok false if(collidebottom false) wok true if(collideright true) aok false if(collideright false) aok true if(collideleft true) dok false if(collideleft false) dok true My problem is if the tank doesn't collide the other object any more, the keys stay blocked... Could you help me with that? |
18 | How would I move something around inside of a sphere without it going outside of the sphere? I want to be able to do this, but not go outside of the 4.4 meter limit, the radius is 4.4 meters, and it has zero gravity and no friction. I have a hard time explaining this, but imagine holding a hollow sphere with a little ball inside, when you shake it around the ball goes around the inside, I need something like that, but with zero gravity and no friction. I wasn't really sure how to do this, but I tried void Slide() if (slide) for (uint32 t deviceIndex 0 deviceIndex lt vr k unMaxTrackedDeviceCount deviceIndex ) glm vec3 position devicePos deviceIndex .xyz() if (sqrt(pow(position.x 0.35, 2) pow(position.y 1.75, 2) pow(position.z 0.85, 2)) gt 4.4) if (abs(position.x) gt abs(position.y) amp amp abs(position.x) gt abs(position.z)) if (position.x gt 0) velocity.x ((abs(velocity.y)) (abs(velocity.z))) 2 else velocity.x ((abs(velocity.y) 1) (abs(velocity.z) 1)) 2 if (abs(position.y) gt abs(position.x) amp amp abs(position.y) gt abs(position.z)) if (position.y gt 0) velocity.y ((abs(velocity.x)) (abs(velocity.z))) 2 else velocity.y ((abs(velocity.x) 1) (abs(velocity.z) 1)) 2 if (abs(position.z) gt abs(position.x) amp amp abs(position.z) gt abs(position.y)) if (position.z gt 0) velocity.z ((abs(velocity.x)) (abs(velocity.y))) 2 else velocity.z ((abs(velocity.x) 1) (abs(velocity.y) 1)) 2 |
18 | Detect collision in Blender I am trying to write a Python function for Blender(2.66) game engine, that permits me to detect collision between two objects. I tried to read the documentation, but it's very confusing, and I don't understand it. Someone have an example how to do it? |
18 | How to build bullet (hit) damage detection in Augmented Reality to a real life person acting as an opponent? I am building an Android AR game using ARcore 1.18 in Unity 2019.4.5f1 (LTS). Now I want to create something like bullet damage detection just like it is built in a normal Unity 3D game. Of course, the biggest problem is how can I even detect the real person's hitbox like it is done in a normal game? I need to somehow be able to attach the bullet damage script to the body of the real life person in real time. Has anyone tried this before? How can we achieve this? I understand if I might not get a spoonfed tutorial but some help towards what should I be doing to achieve this will be greatly appreciated. I see some other FPS Augmented Reality games which either uses Laser Tag (Father.io) or Barcodes to scan the opponents. These are definitely some great ideas to create an FPS game experience but still, if possible, I want to try it with just the mobile camera without any external support. I am ready to bear some accuracy loss ) |
18 | Platformer movement and collisions I'm working on a platformer but I'm stuck at the player movement and collisions. Right now I'm not including the grid at all in the movement, but it's time I do it. I've read this article on how to do it. But there's no real code examples just theory. I like the second example and that's the one I'm going for. I want the movement to be smooth, and the player should be able to run in between squares from my map array. This means I have to get tile information from the array, and according to that allow forbid my player to move in that direction. And that's where I'm stuck. My array is a bunch of 1's and 0's right now. I know how to calculate a hitbox around the player, but how do I compare that to the array in an efficiant way? UPDATE I've been playing around with this for a while now, and the only thing I came up with is using player X and Y which is in pixels, dividing by tile size, and getting a rough estimate on the map. Then I make it an AABB by adding its width and height to get the corners. This showed to be very unreliable though, and I would really need some help on how to structure this. |
18 | How can I do fast Triangle Square vs Triangle collision detection? I have a game world where the objects are in a grid based environment with the following restrictions. All of the triangles are 45 90 45 triangles that are unit length. They can only rotate 90 . The squares are of unit length and can not rotate (not that it matters) I have the Square vs Square detection down and it is very very solid and very fast (max vs min on x and y values) Wondering if there are any tricks I can employ since I have these restrictions on the triangles? |
18 | Basic 3D Collision detection in XNA 4.0 I have a problem with detecting collision between 2 models using BoundingSpheres in XNA 4.0. The code I'm using i very simple private bool IsCollision(Model model1, Matrix world1, Model model2, Matrix world2) for (int meshIndex1 0 meshIndex1 lt model1.Meshes.Count meshIndex1 ) BoundingSphere sphere1 model1.Meshes meshIndex1 .BoundingSphere sphere1 sphere1.Transform(world1) for (int meshIndex2 0 meshIndex2 lt model2.Meshes.Count meshIndex2 ) BoundingSphere sphere2 model2.Meshes meshIndex2 .BoundingSphere sphere2 sphere2.Transform(world2) if (sphere1.Intersects(sphere2)) return true return false The problem I'm getting is that when I call this method from the Update method, the program behaves as if this method always returns true value (which of course is not correct). The code for calling is very simple (although this is only the test code) if (IsCollision(model1, worldModel1, model2, worldModel2)) Window.Title "Intersects" What is causing this? The way Im drawing the scene is to load the number of elements and their coordinates from a file like this (it is called from Update method) OpenFileDialog Otvaranje new OpenFileDialog() if (ks.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.L)) this.GraphicsDevice.Clear(Color.CornflowerBlue) Otvaranje.ShowDialog() try using (StreamReader sr new StreamReader(Otvaranje.FileName)) String linija while ((linija sr.ReadLine()) ! null) red linija.Split(',') model red 0 x red 1 y red 2 z red 3 elementi.Add(Convert.ToInt32(model)) podatci.Add(new Vector3(Convert.ToSingle(x), Convert.ToSingle(y), Convert.ToSinglez))) sfere.Add(new BoundingSphere(new Vector3(Convert.ToSingle(x), Convert.ToSingle(y), Convert.ToSingle(z)), 1f)) And then in the Update() method I had the following code (this was my first attempt) if(sfere.Count ! 0) for(int i 1 i lt sfere.Count i ) if(sfere 0 .Intersects(sfere i )) Window.Title "Intersects" This code never returned that collision is true because the bounding boxes are moving when the box moves, and I don't know why. The code that moves the box is this if (Microsoft.Xna.Framework.Input.ButtonState.Pressed Mouse.GetState().LeftButton) worldKutija Matrix.CreateTranslation(new Vector3(0.01f, 0f, 0f)) worldKutija So if the model is set to be the box it is drawn into the worldKutija, and all other models are drawn into world matrix so they would not move with the box model. So why are their BoundingSpheres moving? After this started happening I tried the code I posted in the original question, and got the problems I was talking about |
18 | Collisions between players in multiplayer racing game I'm creating a simple racing game (spaceships, no gravity) using p2.js, phaser and node.js. What I have done Client receives world state from server extrapolate other players based on latest velocity position from server check if client side prediction was correct if no apply position from server and process inputs that server was not aware of. fixed physics step Server receives inputs from clients and apply fixed physics step sends world state to each client Now I'm struggling with collisions between players. Colliding player is jumping all time during collision. I think it's because client side prediction is not calculating similar results to the server. Server doesn't know all inputs from player (lag). Player doesn't have the same position of colliding player as the server (lag). Combining this two makes the client to resolve collision different than the server and when world state arrives player has to make a big correction. |
18 | How to make space invaders destructible scenery and conform it to a shape? We all like the bases that can be destroyed by chunks being split out, I originally implemented it by making a rectangle filled with individual squares (2x2 pixel size CANVAS rects) that would collision detect with any bullets (On 2 very inefficient). I am now trying to make the base into a shape instead of a boring rectangle. I also want to perform collections of nearby squares when one is hit so that chunks can be taken of the base, instead of just the part that was hit. (easy to do with a rectangular array) Is a 2 dimensianal arry still the best way to acheive this? Is there a way to create this array by somehow performing image analysis of a PNG to populate this array? Transparent parts would hold no base item at that i j . |
18 | Collision handling for grid based games and simulations I'm trying to implement a grid based game where there are many creatures moving in the grid from square to square. I'm having a hard time handling collision with creatures in the grid (multiple creatures trying to move into the same square or cell). Where can I find information on how I should handle a game (or simulation) where multiple creatures in a grid want to move into the same cell but aren't allowed to? It's easy to handle 2 creatures, but handling n object collision is tough. I'm looking for info on how to handle collision in a grid world. I don't expect a specific answer as much as resources or suggestions to find more info. EDIT To clarify, I'm looking for info on HOW TO HANDLE COLLISIONS BETWEEN MULTIPLE OBJECTS IN A GRID. In a grid world where multiple objects want to move into the same cell at the same time, how do I resolve this? Does one object get to move into the cell and the other objects remain stationary? Do I make each object push the other object out of its cell? These are the questions I want to answer. An example of the problem I'm looking to answer Consider a grid where there's 3 creatures who move from tile to tile. What do I do when two creatures, A and B, try moving into the same tile? Let's consider if I allow creature A to move into the tile but creature B remains stationary. What happens if a different creature C wanted to move into the tile that creature B was stuck in? Then creature C also wouldn't be able to move. This would cause an issue if I would evaluate creature C's movement first, telling it that he can move into the tile that creature B is in (because creature B plans to move out) but then creature B ends up never moving out. How do I determine which creatures to evaluate first? Also, how do I avoid this huge chain of creatures being forced to remain stationary (in this example, only 1 3 creatures were able to move). |
18 | Resolving collision with multiple objects I already have SAT implemented for collision detection and MTV computation and it works totally fine when my character collides with only one object. But it's possible that there is a collision with multiple objects at once. How do I handle such cases? How do I evaluate chracter translation using all computed MTVs? Pseudocode of how my code currently looks like Contains objects collision with which was detected during broadphase list lt collider gt overlappingObjects Collider for the character for which I'm trying to solve the collision collider characterCollider response res vec3 translation for(collider in overlappingObjects) test if they actally collide and put collision information in res if they do if(testCollision(characterCollider, collider, res)) translation res.mtv Moving character out of the collided objects characterCollider.offset(translation) This code works incorrectly if overlappingObjects contains more than 1 object. What is the correct solution for such problem? |
18 | Robust "soft" platform collision using SAT We'll start with the questions, then a pile of background How do you rigorously and thoroughly define "soft collision" of the Mario esque type (if I start above, or in a jump my feet apex above a "soft platform", I'll land on it)? Can you suggest a definition in terms of object versus segment (or line, or ray, or whatever similar terrain boundary), in a SAT framework? Any good examples references for soft collision out there, even in non SAT frameworks? Finally, any edge corner cases, literal or otherwise, that might not be obvious? The background 6 years ago, I built a simple AABB object versus line segment terrain collision system for work, based heavily on N Tutorial A Collision Detection and Response. (This goes against my advice to never write physics collision for production code oneself, but we had strange requirements no FPU, blazingly fast SRAM and bus, and a relatively slow CPU.) Over the years, we've dealt with a number of (sometimes quite literal) "corner cases", including how we deal with fast moving objects (currently very fine grained multisampling), order of collision resolution, et cetera. This is the usual difficult stuff for na ve SAT, it would seem. Recently another issue with our "soft collision" that is, platforms one can jump "up" through, but not fall "down" through (where "up" and "down" are relative to a unit normal off the line segment) has cropped up. This has me wondering if I've "stated the problem" correctly vis a vis soft platforms. As background, the bug in this case involved characters jumping with an arc such that their "head" just hit the bottom of the soft line segment. Our collision system does, roughly early miss if movement.dot( segmentUnitNormal ) gt 0 moving away from segment, for all segments (debatable whether this should be here, but probably largely irrelevant for this problem) normal three axis SAT (x axis, y axis, and line axis) with miss if any axis shows separation compute proposed projection to displace box out of segment if hit late miss unless 0 lt projection.dot( segmentUnitNormal ) lt 1 for "soft" segments only finally, hit Step 3 specifically the 0 part of 0 lt is the issue here. (On the other end of the range, the choice of 1 as cutoff for maximum interpenetration is arbitrary it's based on our multisample worst case projection response.) Amusingly, the comment above step 3 in the code says something like "Miss unless we started 'above' the segment, or if interpenetration is too deep." The logic as stated says nothing about starting above, instead dealing only with response along unit normal. As mentioned, the 0 case here is the issue if the character's "head" hits the segment exactly at the peak of his jump and we compute a zero response, we'll treat that as a hit, when we'd expect to only get hits when our "feet" are at or just above the segment. We could just exclude the 0 case here, and deal with a little "bounce" when resting on our soft platform, but then we'd have strange cases where we might not seem to be in contact with the world geometry every other frame, which has other implications for the animation system and the like. I'd like to preserve 0 interpenetration hit behavior. I have a few possible solutions, mostly boiling down to things like "check if AABB centerpoint started on the correct side of the segment", or "retain the directionality of the projection even if it collapses to zero length" (something like a "signed zero" here we already have this from our SAT calculations earlier), ...coupled with a little more care re whether we're using "computed projection along the line axis" versus "shortest computed projection" in these tests. All of these solutions seem to be robust, in my initial tests. But it has me wondering if I'm missing something obvious hence the questions above. |
18 | Applying statements to a single instance in Game Maker? I'm currently in the process of making a platformer, and am currently in the process of creating "depth" into my game, by making Up Down W S control your depth. (Come closer to screen, go further). The reason I chose to do this is so I can walk around stairs, go behind tables, etc. But I have run into a problem. When I call in my player code, if (depth oWall.depth) code , it is applying to every single wall ever. Is there a way to only make it apply to the object you are currently touching? Here is my code so far Collision TODO Make "depth" apply to a singular instance. if (depth oWall.depth) Colliding with a wall on the Horizontal Axis, causes the player to stop moving. if (place meeting(x h speed, y, oWall)) while(!place meeting(x sign(h speed), y, oWall)) x sign(h speed) h speed 0 Colliding with a wall on the Vertical Axis, causes the player to stop moving. if (place meeting(x, y v speed, oWall)) while(!place meeting(x, y sign(v speed), oWall)) y sign(v speed) v speed 0 Hope you understand what I'm asking. |
18 | Bounding Box Collision Glitching Problem (Pygame) So far the "Bounding Box" method is the only one that I know. It's efficient enough to deal with simple games. Nevertheless, the game I'm developing is not that simple anymore and for that reason, I've made a simplified example of the problem. (It's worth noticing that I don't have rotating sprites on my game or anything like that. After showing the code, I'll explain better). Here's the whole code from pygame import DONE False screen display.set mode((1024,768)) class Thing() def init (self,x,y,w,h,s,c) self.x x self.y y self.w w self.h h self.s s self.sur Surface((64,48)) draw.rect(self.sur,c,(self.x,self.y,w,h),1) self.sur.fill(c) def draw(self) screen.blit(self.sur,(self.x,self.y)) def move(self,x) if key.get pressed() K w or key.get pressed() K UP if x 1 self.y self.s else self.y self.s if key.get pressed() K s or key.get pressed() K DOWN if x 1 self.y self.s else self.y self.s if key.get pressed() K a or key.get pressed() K LEFT if x 1 self.x self.s else self.x self.s if key.get pressed() K d or key.get pressed() K RIGHT if x 1 self.x self.s else self.x self.s def warp(self) if self.y lt 48 self.y 768 if self.y gt 768 48 self.y 0 if self.x lt 64 self.x 1024 64 if self.x gt 1024 64 self.x 64 r1 Thing(0,0,64,48,1,(0,255,0)) r2 Thing(6 64,6 48,64,48,1,(255,0,0)) while not DONE screen.fill((0,0,0)) r2.draw() r1.draw() If not intersecting, then moves, else, it moves in the opposite direction. if not ((((r1.x r1.w) gt (r2.x r1.s)) and (r1.x lt ((r2.x r2.w) r1.s))) and (((r1.y r1.h) gt (r2.y r1.s)) and (r1.y lt ((r2.y r2.h) r1.s)))) r1.move(1) else r1.move(0) r1.warp() if key.get pressed() K ESCAPE DONE True for ev in event.get() if ev.type QUIT DONE True display.update() quit() The problem In my actual game, the grid is fixed and each tile has 64 by 48 pixels. I know how to deal with collision perfectly if I moved by that size. Nevertheless, obviously, the player moves really fast. In the example, the collision is detected pretty well (Just as I see in many examples throughout the internet). The problem is that if I put the player to move WHEN IS NOT intersecting, then, when it touches the obstacle, it does not move anymore. Giving that problem, I began switching the directions, but then, when it touches and I press the opposite key, it "glitches through". My actual game has many walls, and the player will touch them many times, and I can't afford letting the player go through them. The code problem illustrated When the player goes towards the wall (Fine). When the player goes towards the wall and press the opposite direction. (It glitches through). Here is the logic I've designed before implementing it I don't know any other method, and I really just want to have walls fixed in a grid, but move by 1 or 2 or 3 pixels (Slowly) and have perfect collision without glitching possibilities. What do you suggest? |
18 | Given a plane and a point, how can I determine which side of the plane the point is on? Given the point Vector pos new Vector(0.0, 0.20156815648078918, 78.30000305175781, 1.0) and the plane (triangle) Vector a new Vector( 6.599999904632568, 0.0, 78.5, 1.0) Vector b new Vector(6.599999904632568, 0.0, 78.5, 1.0) Vector c new Vector(6.599999904632568, 4.400000095367432, 78.5, 1.0) I want to get a plane normal pointing in the direction of pos Getting plane normal Vector ac Vector.Subtract(a,c) Vector bc Vector.Subtract(b,c) Vector planeNormal Vector.CrossProduct(bc, ac) Testing which side of the plane the point is on double dprod Vector.DotProduct(planeNormal, pos) if (dprod lt 0) planeNormal.Negate() But this method is wrong. The resulting planeNormal points in the negative Z direction, so it should not be negated. Is there a best practise for this? Please help me, I fail massively math ) |
18 | Using PhysX, how can I predict where I will need to generate procedural terrain collision shapes? In this situation, I have terrain height values I generate procedurally. For rendering, I use the camera's position to generate an appropriate sized height map. For collision, however, I need to have height fields generated in areas where objects may intersect. My current potential solution, which may be naive, is to iterate over all "awake" physics actors, use their bounds extents and velocities to generate spheres in which they may reside after a physics update, then generate height values for ranges encompassing clustered groups of actors. Much of that data is likely already calculated by PhysX already, however. Is there some API, maybe a set of queries, even callbacks from the spatial system, that I could use to predict where terrain height values will be needed? |
18 | Should I use Box2D for collision detection only (not simulating physics)? I'm using Box2D only to check collisions and for no physical simulation. I create bodies (and shapes for them) and use my own code to move them, by setting their velocities and positions every frame. I only fetch collision data from the Box2D world. Is this a good idea? For example, can it cause undefined behaviour from Box2D? Is there a more performance friendly way of dealing with different shape collision detections? Do better methods exist for this? |
18 | How do I detect a line collison in LIBGDX? I am drawing a continuous line using Pixmap. I want to check for a collision intersection of my line with the already drawn line. |
18 | How do I determine if one polygon completely contains another? I have 2 polygons. I know the vertex coordinates of both polygons. What's the best way to check if one is completely inside the other? For example, the algorithm should only recognize the black trapezoid below as being contained |
18 | 2D Collision detection and design So, listening to this very smart piece of advice, I've already completed a basic Tetris game. Moving on, I started a small breakout. But suddenly a nightmare came. Collisions. Since I've been struggling with this a lot, I read a bunch of article of the web. Being a beginner, I thought that, in the first approach, I would only use Rectangle to detect collisions. Right. Now I still have some problems. First of all, all the articles I stumbled upon on the Internet told me how to detect collisions, e.g. checking if objects A and B collided with each other. But it is not what I really need. In order to respond properly, I need to tell my objects if the collision happened on the X or Y axis and then setting the new velocity according to some rules. The problem is that there are so many possibilities when making the distinction between types of collisions that I don't think I've taken the right path. The second point (which, I believe, is really tied with the first) is the pattern in which the detection and the resolution of a collision happen. Right now, I have a CollidableObject classes and a CollisionDetector classes which knows about these objects. Each frame, the detector is looking for collision (or at least for me, is trying) and when he finds one, it alerts each collided object, saying "Hey you ! You've have collided with Z on the X axis, change that velocity now." and the object abides. The main issue right now is that I can detect the collision axis and therefore, when saying "Hey you ! You collided !", I cannot respond properly. In which direction should my velocity change ? I've been thinking a lot about this lately, trying to figure it out on my own, but I haven't find something that I liked so I am asking here now. Thank you for your answers ! (Note I don't know if this is relevant, but I'm coding in C using SDL) |
18 | 3D models and hit detection I'm currently trying to create a game that involves the inside of a cube, which i will make in Maya. My question is what is the best way to create a model with hit detection in mind? For example my model will be a cube that you can walk inside of, so should i make the cube as a one model or make one wall and put it together inside XNA? The reason I ask this is because I'm sure that if I create a whole cube and then use XNA's bounding rectangle method, hit detection will always be true because the bounding rectangle will encompass the whole cube, making collision detection inside the cube non existent without the use of hard values. Whereas separate walls would make the process easier because i will checking against separate walls instead of the whole thing. To add to the problem, I also have doors in the walls so hit detection for the walls in that area need to be turned off. What is the best way to do this? |
18 | Exact collision detection for high detail deformable triangular meshes What robust methods or approaches exist for exact collision detection involving high detail, deformable geometry? The kind of mesh I am describing is a surface that is specified as a triangulated polyhedron and looks very similar to this For the specific application I am working on, I need to find all the contact points for colliding meshes that undergo subsequent deformation. Possible deformations that may occur during a collisional event 1) the mesh decomposes, or fragments into smaller (triangulated) meshes 2) the mesh retains integrity but the vertex values of it's surface change 3) both of the above deformations occur There is no real time constraint accuracy rather than performance is the critical factor. |
18 | TileMap or Voxel collision detection I have a conceptual question In the case of Tile Map, each block has the information from the enemies who are going about it. But what if some of these enemies are far greater than the block? I have to have the same element in each of the information blocks? And updating the position must clear each block? If I have large and small enemies, it means that each block will have a list of enemies? Now, in the case of Voxel Map In Minecraft, for example, its character and most enemies x and z dimensions is smaller than one block, but its height (y) is greater than one block. This means that these elements will record information in two blocks? and in the case of a "Gast," which is much larger? I'm using Google Translate, so sorry if my english is very bad. Thanks in advance. |
18 | multiple contacts for SAT collision detection I have implemented SAT algorithm for obb obb intersection and I am able to generate a contact for this collision type. My problem is that SAT only generate ONE contact and in many situation I need more than one contact. For example, If I have a big cube and above it I have a small cube I need two contact (two contacts in 2D and 4 contacts in 3D) one for each bottom vertex of small cube. My question is how can I generate more than one contacts with SAT? Thanks. |
18 | Is an extra collision mesh for level data worth the hassle? What is the optimal approach for collision detection with the environment in an 3D engine (with triangle mesh based geometry, no bsp)? A) Use the render mesh no need for additional work for artists to fiddle with collision detection high detail is harder for physics calculation maybe use collidable flags for materials compute the collision mesh from the render mesh B) Use an additional collision mesh faster more optimal collision detection additional work (either by the artist or by the programmer who has to develop an algorithm to compute it from the render mesh) more memory useage How do AAA title handle this? And what are the indie dev's approaches? |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.