collision-detection

Translation direction in separating axis theorem

风格不统一 提交于 2019-12-12 09:24:39
问题 I have implementen the separating axis theorem in java. The collision detection itself works great. But i am stuck when it comes to resolve the collision. my method to get the translation looks like this: public float getOverlap(final Projection other) { float start = m_min > other.m_min ? m_min : other.m_min; float end = m_max < other.m_max ? m_max : other.m_max; float translation = end - start; return translation; } Lets say the projection of the two rectangles in the picture looks like

Unity3d Is there something like Mesh Collider for 2D objects?

£可爱£侵袭症+ 提交于 2019-12-12 09:15:02
问题 Im making simple 2D game, I designed the "way" the player going through in the game. If the player touches the wall the game is over, so I must detect collisions. At first I created the walls from sprites, but then I realized there is no 2D collider that suit himself to the shape of the sprit(it was to difficult to create the collider manually from a lot of smaller polygon and circle colliders), so I made all the walls that builds the "way" 3D objects(.dae files with z=0.001), and added them

Collision detection in HTML5 canvas. Optimization too

自作多情 提交于 2019-12-12 09:13:15
问题 I am making a platform game, but i have a problem with my collision detection. I've made a function that draws a tile on the screen/map. In that function is my collision detection, it works fine when only one tile is drawn, but when i created "stairs" with three tiles, the first tile doesnt work propertly. The player is just being "pushed" up on the tile. The side detection isn't working. And the other tiles are working just fine. Here is the code for collision detection and tile drawing: /

Circle to Circle Segment Collision

那年仲夏 提交于 2019-12-12 07:12:40
问题 I'm struggling to find a rock solid solution to detecting collisions between a circle and a circle segment. Imagine a Field of View cone for a game enemy, with the circles representing objects of interest. The diagram at the bottom is something I drew to try and work out some possible cases, but i'm sure there are more. I understand how to quickly exlude extreme cases, I discard any targets that don't collide with the entire circle, and any cases where the center of the main circle is within

Powerups not colliding with player (Pygame)

感情迁移 提交于 2019-12-12 04:58:00
问题 I've been having trouble getting my powerups to disappear upon colliding with the player character. I've been able to get powerups to drop upon killing enemies with bullets, but I can't seem to collect them. I've listed my project so far. I've tried messing with a couple functions (pygame.sprite.spritecollide() and pygame.rect.colliderect()) but neither seemed to work. I can't seem to figure out if the problem is in my Player or Power class or in the "while" loop at the bottom. import pygame,

Detect whether a specific part of body collided with another body in box2d

只谈情不闲聊 提交于 2019-12-12 04:37:38
问题 Kindly suggest some explanation or code regarding how can i detect collision between a specific part of one body with another body in box2d with libgdx.I am able to detect simple collision between two bodies using Contact Listener as mentioned hereBut I also want to check which part of bodies are ovelapping . Thanks, 回答1: The ContactListener provides you with Contact as a callback parameter. Those contacts will tell you which Fixtures did collide via contact.getFixtureA() and contact

Comparing two sprites colors based on random colorization?

孤街浪徒 提交于 2019-12-12 03:37:47
问题 This code colorizes my ball. var colorize1 = SKAction.colorizeWithColor(.redColor(), colorBlendFactor: 1.0, duration: 0.3) var colorize2 = SKAction.colorizeWithColor(.greenColor(), colorBlendFactor: 1.0, duration: 0.3) var colorize3 = SKAction.colorizeWithColor(.blueColor(), colorBlendFactor: 1.0, duration: 0.3) var actions = [colorize1, colorize2, colorize3] var randomIndex = Int(arc4random_uniform(3)) var action = actions[randomIndex] let seconds = 0.14 let delay = seconds * Double(NSEC_PER

camera and terrain collision on three.js

核能气质少年 提交于 2019-12-12 03:33:33
问题 I have a building model created with sketchup, exported as collada file and loaded to three.js with colladaloader. Everything works fine except that the camera can pass through walls. How do I prevent this? So far I have tried with Raycasting, but I think something is wrong. this is how the model is loaded loader.options.convertUpAxis = true; loader.load( 'model/cityhall.dae', function ( collada ) { dae = collada.scene; skin = collada.skins[ 0 ]; model_geometry = collada.scene.children[ 0 ]

collision detection using createjs

南笙酒味 提交于 2019-12-12 03:08:20
问题 I am a complete novice in createjs and wanted some guidance over this topic of collision detection. I have created some text objects using font awesome using a loop. Next I saved them in variable objx as id along with updating its position coordinates (x,y) in it. And here is the code for collision detection: createjs.Ticker.addEventListener("tick", function(){ var jx,jy,jt,t; for(var i = 0 ; i < objx.length-1 ; i++)objx[i].id.color="#8B0000"; for(var i = 0 ; i < objx.length-1 ; i++){ x =

Circle and Rectangle collision

左心房为你撑大大i 提交于 2019-12-12 02:35:49
问题 I have a program in Processing for a bouncing ball and a rectangle. I can get the collision for the sides of the rectangle correct, but I have no idea how to get the corners. This is what I have so far: int radius = 20; float circleX, circleY; //positions float vx = 3, vy = 3; //velocities float boxW, boxH; //bat dimensions void setup(){ size(400,400); ellipseMode(RADIUS); rectMode(RADIUS); circleX = width/4; circleY = height/4; boxW = 50; boxH = 20; } void draw(){ background(0); circleX +=