collision-detection

How to fix circles overlap in collision response?

南笙酒味 提交于 2019-12-08 05:48:31
问题 Since in the digital world a real collision almost never happens, we will always have a situation where the "colliding" balls overlap. How to put back balls in situation where they collide perfectly without overlap? I would solve this problem with a posteriori approach (in two dimensions). In short I have to solve this equation for t: Where: is a number that answers to the question: how many frames ago did the collision happen perfectly? is the center of the first ball is the center of the

Collision Detection with Ceramic Tile Engine & Box 2D

隐身守侯 提交于 2019-12-08 05:19:14
问题 Follow up of this question, Storyboard with Ceramic Tile Engine, and with Collision Detection is still a mystery. Here is the code: -- hide status bar display.setStatusBar(display.HiddenStatusBar) local storyboard = require("storyboard") --Set up the physics world local physics = require("physics") physics.start() physics.setGravity(0, 0) physics.setDrawMode('hybrid') local scene = storyboard.newScene() local widget = require("widget") -- Add Hero to Physics local hero = display.newImage(

Collision detection for an arc of a circle

雨燕双飞 提交于 2019-12-08 02:49:26
问题 So how do i implement the collision detection for an arc of a circle? Will i have to use the Box 2d collision or can i do it some other way using Rectangle or stuff like that? BTW I hate box2d because i dont understand most of the things in it, so if there is a solution that excludes the box2d, it will be very much appreciated. The yellow arc keeps on rotating over the black circle. How do i implement collision detection in here? Please help ! Thanks! 回答1: To avoid using Box2D you could

Why is there multiple collision calls Sprite Kit Swift

有些话、适合烂在心里 提交于 2019-12-08 02:21:42
问题 I am building an iOS swift game with collision. The hero is being bombarded by small stars coming from the right side of the screen. Every time a star hits the hero, the score is iterated and the star is removed. But, more than one point is added to the score. Node Set-up: var star = SKSpriteNode(imageNamed: "star") star.size = CGSizeMake(30, 30) star.zPosition = 10 var starPhysicsRect = CGRectMake(star.position.x - star.frame.size.width / 2, star.position.y - star.frame.size.width / 2, star

Collision Normal of two points

青春壹個敷衍的年華 提交于 2019-12-08 00:08:29
问题 I'm trying to calculate the collision normal of two points. I need this for the collision response equations to calculate the new angular and linear velocities. This scenario happens when, for example, the corners of two 2d or 3d boxes collide with each other. What would be their collision normal? I now that in the case of a vertex and face collision the collision normal would be just the normal of the face. 回答1: It is undefined. Technically, the collision normal should be the normal at the

On overlap, player gets stuck libgdx Rectangle

岁酱吖の 提交于 2019-12-07 23:16:03
问题 So I'm working on a collision detection code and what i do is when the user rectangle overlaps the rectangle where they cant move, I stop them from moving. So if im moving right and I hit a wall i cant move forward. This works. However if after i hit that wall, I want to move down or up form that point, I get stuck. This is how i check if the user has colidded private void checkCollision() { for (int x = 0; x < amount; x++) { if (collsionRect[x].overlaps(user)) { Gdx.app.log(ChromeGame.LOG,

How to do pixel perfect collision on many sprites in cocos2d?

隐身守侯 提交于 2019-12-07 16:41:03
问题 in my app I have a player and many enemies (about 100+)..I don't want to use CGRects because it doesn't fits to the enemies. Is there any example how to do pixel perfect collision detection in cocos2d with many sprites? Some explaination would be great ;) Thank you very much! EDIT : I'm using CCSprite and .png files. the png has transparency but it should only detect a collision on non-transparency pixels. Edit: My enemies are round. 回答1: Circle-circle collision is the easiest.. And computing

How do I detect collision detection in flash AS3?

白昼怎懂夜的黑 提交于 2019-12-07 13:28:54
问题 I wanted to create a maze in flash AS3, with the user guiding the character. I tried using this (below) but this will require me to make all the maze walls individual and setting collision detection to each one. Is there an easier way of accomplishing the same thing? monkey.addEventListener( Event.ENTER_FRAME, handleCollision) function handleCollision( e:Event ):void { if(monkey.hitTestObject(wall)) { trace("HIT"); } else { trace("MISS"); } } 回答1: You can use the Collision Detection Kit :

RigidBody2D freeze X position

谁都会走 提交于 2019-12-07 13:17:25
问题 I'm wondering if there is a way to emulate the following line of code using Unity's RigidBody2D as opposed to using a normal RigidBody. rigidbody.constraints = RigidbodyConstraints.FreezePositionX; I wanting my players x position to freeze when it collides with something. Whilst I could use the above, it would require I rework all my 2D collisions to work with the 3D collision. A pain I'd rather avoid. 回答1: This is due to the Box2D engine use to do the simulation. It does not directly provide

Is an imageData CanvasPixelArray directly available to a canvas WebGL context?

坚强是说给别人听的谎言 提交于 2019-12-07 08:07:29
问题 I'm using Three.js to draw 3D models onto a webgl canvas renderer above simple DOM elements, and I need to do collision detection between them. My currently working method is to use renderer.domElement.toDataURL(), load this as an imageData object then draw this onto a separate 2D canvas context, then pull the getImageData() pixel array and iterate through using this awesome pixel collision function. This is incredibly slow, and pulls my frame rate down to a nearly unplayable ~5-8 FPS.