game-physics

How to not allow kinematic physics bodies to pass through static bodies?

本小妞迷上赌 提交于 2019-12-14 02:26:18
问题 My game scene consist of four walls, which are static bodies, and one platform plate, which is of type kinematic and slides only horizontally, something like the picture below. The platform body moves based on acceleration sensor, see this codes @Override public void onAccelerationChanged(AccelerationData pAccelerationData) { mPlatformBody.setLinearVelocity(pAccelerationData.getX() * 10, 0); } My problem is when the platform goes off the boundary walls, which it should not. For resolving this

SKPhysicsBody Change Center of Mass

牧云@^-^@ 提交于 2019-12-14 01:29:54
问题 I am currently working on a game where I have a picture of a kind of cylindrical object, and I make an SKPhysicsBody with the following: self.oval.node.physicsBody = SKPhysicsBody(texture: self.oval.node.texture, size: self.oval.node.size) This method creates a nice shape around the node, however, the center of gravity is way off... It balances on the tip of the oval. Is there anyway to change that so it balances where the heaviest part should in theory be? Thanks! 回答1: The center of mass can

Unity3D Character Continuously Moving Issue

冷暖自知 提交于 2019-12-13 21:45:12
问题 so I'm working on a project in Unity3D and I'm having the following issue: When I initially start the game, the character is not moving, which is intended. Then, when I hit "W" to move, my character starts moving and animates. However, when I let off the key, she doesn't stop moving forward. Even if I hit the "S" key to move backward, after I let up, she starts moving forward again while no keys are pressed, and for the life of me I can't figure out why. Here's the script I'm using on her if

Box2d :roll soft body ball

让人想犯罪 __ 提交于 2019-12-13 19:23:43
问题 I made a soft body ball int box2d that looks like that: Every point of the circle is a box2d body and every line is a distance joint. How can i roll it? I don't want to change the world gravity and just let it roll , I want it to start spinning from the center (not every circle point independent). I just need the geeneral idea ,not code. 回答1: The general idea is to apply the right force to each body. If you want rotation - these forces are normals to the vectors from the center of the ball to

Android AndEngine: Simple sprite collision

こ雲淡風輕ζ 提交于 2019-12-13 18:27:11
问题 I am new to AndEngine game development (or game development in general) and I am working on a very simple game. The setting is that I have 4 main sprites in the game: a.) Fighter Plane b.) Tank c.) Foot soldiers d.) Bomb The game is in a current infinite loop. The fighter plane comes out from the left, zooms across the screen and comes out the right again continuously every second. The Tank comes out from the left side of the screen, makes its way to the middle of the screen, drops off some

Rotating Images & Pixel Collision Detection

时间秒杀一切 提交于 2019-12-13 15:02:50
问题 I've got this game in this plunker. When the swords are not rotating, it all works fine (you can check by uncommenting lines 221 and commenting out 222-223). When they are rotating like in the plunker above, the collision doesn't work well. I guess that's because the "getImageData" remembers the old images, but I gather it's an expensive thing to recalculate over and over again. Is there a better way to rotate my images and make this work? Or do I have to recalculate their pixel map? Code of

Pygame, simple physics engine, how to hold points between planes?

筅森魡賤 提交于 2019-12-13 05:24:36
问题 I'm trying to write this tutorial in Pygame(Python) and having problems about holding points between planes. My code is: fiz2.py Vector class: vector.py If you move mouse on the Pygame screen, the planes will rotate. And when the planes are rotating, points are passing through planes and going outside. I tried to fix points' positions on every iteration but they still passed the planes. I have no idea about where should I fix their positions. NOTE: I know my code is a little bit messy, this

moving physics body at a constant speed

偶尔善良 提交于 2019-12-13 05:08:56
问题 I am working with a 2D physics engine that has the typical physics properties on a rigidbody get/set mass, friction, bounce, gravity, linear damping, linear velocity, impulses. I would like to move this rigidbody at a constant speed, is there some formula that I can use to uses those forces to move the body at a constant speed. 回答1: Constant speed can only be achieved in a universe with no other matter. So, you've got to remove friction(no air to bump into), gravity(no other mass pulling on

Collision detection while using rectangles

五迷三道 提交于 2019-12-13 04:37:57
问题 So I understand that I'm not coding this the best way possible at the moment; this is a sort of test run. What I'm trying to do is wall collisions using rectangles and the intersects property (sorry if I'm not using the correct terminology). So far I have 2 rectangles on screen. 1 the player controls and the other which the play is colliding with. When they collide the player stops moving. The problem is that if the player is trying to move into the rectangle while they are already colliding

Unable to fix broken ball movement in pygame pong

ε祈祈猫儿з 提交于 2019-12-13 04:14:10
问题 I'm fairly new to programming, game programming especially. I'm trying to make pong using pygame, but have run into a slight issue. Essentially, the ball hits a paddle, stops, and then keeps going once the paddle is out of the way. Obviously I want the ball to bounce back, but I can't figure out why it won't, when I've coded (what I thought was) the appropriate logic for ball-paddle collisions. Here's my code: # importing stuff import sys, pygame from pygame.locals import * # starting pygame