game-physics

AI of spaceship's propulsion: land a 3D ship at position=0 and angle=0

对着背影说爱祢 提交于 2019-11-27 20:04:55
问题 This is a very difficult problem about how to maneuver a spaceship that can both translate and rotate in 3D, for a space game. The spaceship has n jets placing in various positions and directions. Transformation of i -th jet relative to the CM of spaceship is constant = Ti . Transformation is a tuple of position and orientation (quaternion or matrix 3x3 or, less preferable, Euler angles). A transformation can also be denoted by a single matrix 4x4. In other words, all jet are glued to the

How to fix circle and rectangle overlap in collision response?

心不动则不痛 提交于 2019-11-27 18:25:57
Since in the digital world a real collision almost never happens, we will always have a situation where the "colliding" circle overlaps the rectangle. How to put back the circle in the situation where it collides perfectly with the rectangle without overlap? Suppose that the rectangle is stopped (null velocity) and axis-aligned. 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 radius of the circle. is the center

SpriteKit SKPhysicsBody bodyWithTexture is Upside Down

丶灬走出姿态 提交于 2019-11-27 18:23:06
问题 Hi I'm trying to fix this bug with spritekit's physics shape appearing upside down. [SKPhysicsBody bodyWithTexture:monsterTexture size:monsterTexture.size] The first time the monster appears the phsyics body orientation is correct. But the second time and every time after that the monster appears it's physics body is inverted along the Y axis. See picture where skView.showsPhysics = true; so the physics shapes are displayed. The fact that it works correctly the first time makes me think maybe

Path generation for non-intersecting disc movement on a plane

…衆ロ難τιáo~ 提交于 2019-11-27 14:42:23
What I'm looking for I have 300 or fewer discs of equal radius on a plane. At time 0 each disc is at a position. At time 1 each disc is at a potentially different position. I'm looking to generate a 2D path for each disc for times between 0 and 1 such that the discs do not intersect and the paths are relatively efficient (short) and of low curvature if possible. (for example, straight lines are preferable to squiggly lines) Lower computation time is generally more important than exactness of solution. (for example, a little intersection is okay, and I don't necessarily need an optimal result)

SpriteKit physics in Swift - Ball slides against wall instead of reflecting

我的未来我决定 提交于 2019-11-27 08:24:17
I have been creating my own very simple test game based on Breakout while learning SpriteKit (using iOS Games by Tutorials by Ray Wenderlich et al.) to see if I can apply concepts that I have learned. I have decided to simplify my code by using an .sks file to create the sprite nodes and replacing my manual bounds checking and collision with physics bodies. However, my ball keeps running parallel to walls/other rectangles (as in, simply sliding up and down them) any time it collides with them at a steep angle. Here is the relevant code--I have moved the physics body properties into code to

node's position appears constant during physics simulation

妖精的绣舞 提交于 2019-11-27 07:32:59
问题 I'm running some physics on a node. The node moves in all directions, but when tracking it's position it appears to be stationary. func renderer(renderer: SCNSceneRenderer, didSimulatePhysicsAtTime time: NSTimeInterval) { print("position.y: \(starNode.position.y)") The message in the debugger is "position.y: 5.578" (which is the position I assigned in Scene Editor) for every call to renderer:didSimulatePhysicsAtTime method What's going on? 回答1: that a look at the presentationNode property. 来源

Sprite Kit physicsBody.resting behavior

非 Y 不嫁゛ 提交于 2019-11-27 06:54:48
问题 I am using Swift and Sprite Kit to develop a game on XCode Beta 6. In order to detect if all nodes are sleeping, i check their physicsBody.resting property. In update method i print out the result. import SpriteKit class GameScene: SKScene, SKPhysicsContactDelegate { var hero:SKSpriteNode! override func didMoveToView(view: SKView) { self.physicsWorld.gravity = CGVectorMake(0, 0) self.physicsWorld.contactDelegate = self self.physicsBody = SKPhysicsBody(edgeLoopFromRect:self.frame) hero =

SKPhysicsBody bodyWithPolygonFromPath memory leaks

别说谁变了你拦得住时间么 提交于 2019-11-27 06:02:32
问题 I have a strange memory leaks when creating Sprite Kit physics bodies with custom shapes. This is how my implementation looks: CGFloat offsetX = self.frame.size.width * self.anchorPoint.x; CGFloat offsetY = self.frame.size.height * self.anchorPoint.y; CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, 4 - offsetX, 3 - offsetY); CGPathAddLineToPoint(path, NULL, 66 - offsetX, 3 - offsetY); CGPathAddLineToPoint(path, NULL, 35 - offsetX, 57 - offsetY); CGPathCloseSubpath

How to prevent colliders from passing through each other?

霸气de小男生 提交于 2019-11-27 04:19:55
问题 I am having trouble keeping game objects inside of a contained space. When they reach the edge, there is some momentary push back but then they will go right through the wall. I am using a Box Collider on the player, and a Mesh Collider for the level's wall. I am having issues with both a Player Character (a space ship) that the movement is controlled by the player. And with projectiles, which are fire and forget moving at a constant speed. This is my movement code for my player. It is being

Sprite Kit set Min. and Max. for Jump

℡╲_俬逩灬. 提交于 2019-11-27 03:15:51
问题 I want to move a SKSpriteNode on the Y-Axis . The SKSpriteNode called Player has no Velocity .The Player can only jump if a Platform is in contact. Everytime the Screen is touched, I want to give the Player an impulse with a minimum impulse or a maximum impulse If the Screen is tapped shortly, the Minimum impulse should be e.g. y = 50 . If the Screen is hold, that means the finger is on the Screen long, the Maximum should be e.g. y = 100 . But the Player should be also able to jump between