game-physics

Circle/rectangle collision response

可紊 提交于 2019-12-12 09:03:34
问题 So I built some time ago a little Breakout clone , and I wanted to upgrade it a little bit, mostly for the collisions. When I first made it I had a basic " collision " detection between my ball and my brick, which in fact considered the ball as another rectangle. But this created an issue with the edge collisions, so I thought I would change it. The thing is, I found some answers to my problem: for example this image and the last comment of this thread : circle/rect collision reaction but i

Determining Resting contact between sphere and plane when using external forces

有些话、适合烂在心里 提交于 2019-12-12 07:49:39
问题 This question has one major question, and one minor question. I believe I am right in either question from my research, but not both. For my physics loop, the first thing I do is apply a gravitational force to my TotalForce for a rigid body object. I then check for collisions using my TotalForce and my Velocity . My TotalForce is reset to (0, 0, 0) after every physics loop, although I will keep my velocity . I am familiar with doing a collision check between a moving sphere and a static plane

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

Game Physics - Not very life-like

柔情痞子 提交于 2019-12-12 04:59:11
问题 In a simple game (cocos2d) I have a made a small physics engine to move a sprite so that it can jump and stand on platforms ect. To update the position (vertical movement) I use basic kinematics equations in each update: position = oldPosition + velocity(delta) +1/2(gravity)(delta)^2 velocity = oldVelocity + (gravity)(delta) For some reason the game doesn't seem very life-like. It seems to take a long time near the top of an arc, despite how great I make gravity. If I want my sprite to jump

Why does my player move off the screen when I set the libGDX camera's position to the players x and y?

你离开我真会死。 提交于 2019-12-12 04:53:35
问题 for the past few days i have been tinkering around with moving the player with just one camera and having the camera follow the player's x and y. When i searched this up all i found was to move the player and set the camera's x and y to that. But i am having a problem, my player does not stay in the middle of the screen and it is really anoying. If anyone could hep me that would be great. Here is the code. in the create; cam = new OrthographicCamera(); cam.setToOrtho(false, Main.WIDTH, Main

Game Running slow in Android Handsets, no use of textures only using ShapeRenderer to draw shapes

a 夏天 提交于 2019-12-12 03:28:15
问题 I am making a game in which i am making arcs using ShapeRenderer , As i needed to rotate those arcs around the center so i wrote that code only begin and end in render method, I am initializing them in create method , But as the number of arcs increases the game gets slower and slower. I have maximum of 13 arcs and minimum 2 arcs . It running fine till few say 8 arcs and after that it gets slower. Please any one out there if he/she can help, please help... thanks in advance. Render Method is

SKPhysicsJointPin pin position

拥有回忆 提交于 2019-12-12 01:56:26
问题 I'm trying to understand SKPhysicsJointPin a bit better, specifically the anchor point parameter. I understand that the anchor point is the position in the parent node of the two physics bodies concerned. What I don't understand at which point in the participating bodies does the pin go through and if there is a way to control that. To make myself clear, say I'm making a clock with hands so the pin should go in the middle of the circle but for the hands is should go through the edge. So how

What causes the joints of a physics engine to tear?

ぐ巨炮叔叔 提交于 2019-12-12 01:54:04
问题 I will keep this brief, know that what I am talking about happened on Box2d for AS3 in 2009, and it also happens today with a totally separate library p2 physics in JavaScript. Please go to the following 2d ragdoll demo page and spin the ragdoll around by the head quite vigorously. https://schteppe.github.io/p2.js/demos/ragdoll.html You will see the result that the joints separate and turn elastic. This problem prevents me making anything fun with physics. Ball and chains, catapults,

SpriteKit: how to turn touches into vectors of uniform speed?

江枫思渺然 提交于 2019-12-12 01:28:26
问题 I am using touches to set SpriteKit nodes in motion. Currently I do this: //(previous code turns current touch and last touch into thisP and thatP)... CGPoint velocity = CGPointMake(thisP.x - lastP.x, thisP.y - lastP.y); //If the velocity is non-zero, apply it to the node: if (!CGPointEqualToPoint(velocity, CGPointZero)) { [[MyNode physicsBody] applyForce:CGVectorMake(velocity.x, velocity.y)]; } This is very effective at getting the nodes to move different speeds depending on how fast the

Calculating distance travelled by a b2body before it stops in Box2D

自作多情 提交于 2019-12-11 20:47:22
问题 I have a zero gravity world. I have a catapult using which a box2d body is shot into space. I calculate a certain force and apply it to the body along with a certain damping factor. My code hence looks like this: _body->ApplyForce(force, b2Vec2(position.x / PTM_RATIO, position.y / PTM_RATIO)); float damping = 1.5f; _body->SetLinearDamping(damping); I want to calculate the distance it travels before it ultimately stops. What is the correct way to calculate it? I am calculating it using -