game-physics

Determining Resting contact between sphere and plane when using external forces

此生再无相见时 提交于 2019-12-03 12:37:07
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 when using only velocity. However, what if I have other forces besides velocity , such as gravity? I

Optimization of AndEngine game

让人想犯罪 __ 提交于 2019-12-03 05:59:26
问题 I am using java + AndEngine in my game. During the game i have some freezes, i looked for the information and found some steps how to optimize game performance: Avoid GC (garbage collector) to be called in main action in the game: a)don't create objects while gaming; b)don't create unnecessary objects; Optimize code that repeats very often I followed these steps, but never the less i have some freezes during the gameplay. Now i am creating and loading all of the textures before the game

Good 2D Collision Response References

早过忘川 提交于 2019-12-03 04:24:55
问题 Hey, I'm currently looking for various methods of implementing collision response in 2D video games, something similar to this tutorial Metanet has: N Tutorial I'm looking to implement something in XNA, but any language would be fine. I'm more interested in implementing programmatically than actual theory. I'd prefer more beginner friendly material, but I do welcome more advance topics. So could someone suggest some good 2D collision response articles/books? (PS: I'm more interested in

Problem with collision detection of a fast moving ball with a racket controlled by mouse

假如想象 提交于 2019-12-03 02:59:59
In unity, i have a racket which is supposed to hit a ball, and the racket is controlled directly by the mouse, i.e the bat is being moved by the mouse using mouse axes and the using transform.translate() function to move the racket. I expected that Unity3d's physics will not properly translate the racket's movement directly by mouse and impact the ball accordingly, and i would have to write something custom, and it turned out to be true. But the ball's collision is not being detected properly when the racket is moving. When it is still, everything is fine, and the ball behaves as i like. Now i

2D orbital physics

≯℡__Kan透↙ 提交于 2019-12-02 23:01:43
I'm working on a 2D physics engine for a game. I have gravity and masses working, using a simple iterative approach (that I know I'll have to upgrade eventually); I can push the masses around manually and watch them move and it all works as I'd expect. Right now I'm trying to set up the game world in advance with a satellite in a simple circular orbit around a planet. To do this I need to calculate the initial velocity vector of the satellite given the mass of the planet and the desired distance out; this should be trivial, but I cannot for the life of me get it working right. Standard physics

Optimization of AndEngine game

吃可爱长大的小学妹 提交于 2019-12-02 19:38:49
I am using java + AndEngine in my game. During the game i have some freezes, i looked for the information and found some steps how to optimize game performance: Avoid GC (garbage collector) to be called in main action in the game: a)don't create objects while gaming; b)don't create unnecessary objects; Optimize code that repeats very often I followed these steps, but never the less i have some freezes during the gameplay. Now i am creating and loading all of the textures before the game started and don't unload them, is it a bad idea ? How can i optimize the game proccess ? Maybe i have to

Object gets stuck when trying to bounce off screen edges, am I doing this wrong?

这一生的挚爱 提交于 2019-12-02 17:40:37
问题 public class AsteroidMovement : MonoBehaviour { public Vector2 speed; public Vector2 direction; private Vector2 movement; private Vector3 TopScreenBound; private Vector3 BottomScreenBound; // Use this for initialization void Start() { TopScreenBound = Camera.main.ViewportToWorldPoint(new Vector3(0f, 1f, 0f)); BottomScreenBound = Camera.main.ViewportToWorldPoint(new Vector3(0f, 0f, 0f)); } // Update is called once per frame void Update() { if (gameObject.transform.position.y >= TopScreenBound

Good 2D Collision Response References

血红的双手。 提交于 2019-12-02 17:39:28
Hey, I'm currently looking for various methods of implementing collision response in 2D video games, something similar to this tutorial Metanet has: N Tutorial I'm looking to implement something in XNA, but any language would be fine. I'm more interested in implementing programmatically than actual theory. I'd prefer more beginner friendly material, but I do welcome more advance topics. So could someone suggest some good 2D collision response articles/books? (PS: I'm more interested in response than detection) The N tutorial that you mentioned already is a great resource to start with. I also

Homing Missiles, How Do They Work?

喜夏-厌秋 提交于 2019-12-02 13:00:36
What I am trying to create An object that will launch a missile towards the player, if it collides with player, player dies. The Problem How does the missile move towards the player. How do I make the missile move so that it does not instantly move directly towards the player(to slowly move on an angle). I have a formula for the mouse to be the "Player" and the missile to go towards it. mouse = Mouse.GetState(); mousePosition = new Vector2(mouse.X, mouse.Y); A = (mouse.X - Position.X); B = (mouse.Y - Position.Y); C = (A * A) + (B * B); C = (float)Math.Sqrt(C); Angle1 = A / C; Angle2 = B / C;

Keep SKNodes from applying force to each other

我是研究僧i 提交于 2019-12-02 09:29:12
I have two SKNode objects. Their positions change when they collide. How can I prevent that? At the same time, I still want to be able to respond to them contacting via - (void)didBeginContact ; I tried setting both their mass property to 0.0f but that didn't work. You can achieve that by setting category, collision and contact bit masks. uint32_t bodyABitMask = 1<<0; uint32_t bodyBBitMask = 1<<1; //A mask that defines which categories this physics body belongs to. [bodyA setCategoryBitMask:bodyABitMask]; [bodyB setCategoryBitMask:bodyBBitMask]; //A mask that defines which categories of