game-physics

Does Box2D Physics rely on the framerate?

谁说我不能喝 提交于 2019-12-06 09:28:58
I am making a 2D sidescroller game for Android and am thinking of using Box2D for the physics. I would like to know if when using Box2D, if the framerate of the device drops from 60 fps (Android's cap) to, for example, 30 fps will all the physics slow down with it? To elaborate, I'm going to be using real-time online multiplayer and so the framerate cannot be relied upon as a constant. So if one of the devices in the multiplayer game is running at 60 fps and another is at 30 fps and an object should be moving at 10 metres/second will it move at 5 metres/second on the slower device? I would

Bouncing ball in Bullet

旧巷老猫 提交于 2019-12-06 09:24:14
I have two questions with regards to Bullet, but they are related. In the HelloWorldApp, the objective is to get a ball bouncing on a box right? If I wanted to test a plane, could I just add in a btCollisionObject with a btStaticPlaneShape instead of the box? How can I set custom restitution, static and kinetic friction per object? Yes, I believe that should be correct Restitution and friction can be set per object by supplying them to the btRigidBodyConstructionInfo object passed into the btRigidBody constructor For example: btBoxShape * box = new btBoxShape(0.5f,0.5f,0.5f); btVector3 inertia

Collision detection between a BoundingBox and a Sphere in libgdx

南笙酒味 提交于 2019-12-06 08:46:24
In my libgdx game I have 3D BoundingBoxes and Spheres for map and player objects. I want to calculate whether they collide with each other in order to properly simulate the motion of these objects. What method can I use to calculate whether these objects collide/intersect? You can use the following method: public static boolean intersectsWith(BoundingBox boundingBox, Sphere sphere) { float dmin = 0; Vector3 center = sphere.center; Vector3 bmin = boundingBox.getMin(); Vector3 bmax = boundingBox.getMax(); if (center.x < bmin.x) { dmin += Math.pow(center.x - bmin.x, 2); } else if (center.x > bmax

How to improve character control for my 3D game?

一个人想着一个人 提交于 2019-12-06 05:57:54
问题 Since I changed from the helper class CharacterControl to the new BetterCharacterControl I notice some improvements such as pushing other characters is working but my main character has started sliding over steps and can't climb higher steps. I must jump the step above which is not the right way of playing, it should be just walking over. The old helper class CharacterControl had a default way of not sliding, just walking over steps and I think it can be corrected by altering the code where I

Getting direction that SCNNode is facing

为君一笑 提交于 2019-12-06 05:03:30
问题 I am getting lost in how nodespace coordinates and rotation are handled in scenekit. How do I get the direction a node is facing after rotation so I can then apply force in that direction. I assumed that a force along the -z axis applied to the node would always move it forward relative to the node however this is not the case. 回答1: Negative z is the "facing" direction of a node only in its own coordinate space (i.e. the one its children and geometry are positioned in). When you apply a force

Is this plane-ray intersection code correct?

走远了吗. 提交于 2019-12-06 01:57:20
My Plane class has two fields: public Vector3 Norm; //normal vector public double Offset; //signed distance to origin This is the code I use for intersection, and I don't know if it is correct. I double checked my equations and everything, but I would like to get feedback from people more experienced with this. public override Intersection Intersect(Ray ray) { // Create Intersection. Intersection result = new Intersection(); // Find t. double t = - (Vector3.Dot(Norm,ray.Start) + Offset) / (Vector3.Dot(Norm, ray.Dir)); if (t < 0) // the ray does not hit the surface, that is, the surface is

Xna adding gravity to a 2d sprite

我与影子孤独终老i 提交于 2019-12-06 01:47:37
问题 I am trying to simulate gravity in my first xna 2d game. I have the following //Used for Jumping double elapsedAirTime = 0.0; double maxAirTime = 8.35; //End Jumping So I am trying to move the sprite up by a certain amount while the elapsedAirTime < maxAirTime However, there is some issue where my code only seems to move the sprite up once and not multiple times during this segment of time. here is the code in my "player.cs" class, or the update method of the class. if (newState.IsKeyDown

Calculate a trajectory for an object, when given an angle and a velocity in flash

守給你的承諾、 提交于 2019-12-06 00:18:30
I am trying to launch a cannonball from a cannon and have it follow a realistic path. The angle of fire changes depending on the orientation of the cannon (automatically orientates to mouse pointer). So what I'm trying to figure out, is how to move a cannonball along a parabolic path, when given an angle, and a set velocity. I've read that this can be done without complicated trigonometry (never listened to it in highschool), and can be calculated simply by adding gravity to the yVelocity every tick. However, at this moment, I don't know how to calculate the initial yVelocity (again, depending

Java a moving animation (sprite)

↘锁芯ラ 提交于 2019-12-05 20:52:57
Hello i`ve got a problem: when i run this code i get this: on some java forum they said i need to add Graphics2DObject.clearRect(x1, y1, x2, y2); (where`s x1 and y1 is coordinates of the image and x2 y2 is width height of the image.) when i add it to the code i get this: The code(with added function): Main: import java.awt.*; import javax.swing.*; public class Main { public static void main(String []args){ Main b = new Main(); b.run(); } private Sprite sprite; private Animation a; private ScreenManager s; public double sk = 0; private static final DisplayMode modes1[] = { new DisplayMode(800,

magnetism simulation

时光怂恿深爱的人放手 提交于 2019-12-05 20:20:16
Say I have p nodes on a n by m pixel 2D surface, I want the nodes to be attracted to each other such that the further they are apart the strong the attraction. But if the distance between two nodes, say d(A,B) is less than some threshold say k then they start to repel. Could anyone get me started on some code on how to update the co-ordinates of the nodes over time. I have something a little like the code below which is start to do the attraction, but looking for some advice. (P.S. I can not use an existing library to do this). public class node{ float posX; float posY; } public class