_id
int64 0
49
| text
stringlengths 71
4.19k
|
---|---|
6 | Simulating elastic ball collisions quickly escalates to disaster I'm trying to learn HTML canvas and was working on a basic physical simulation, where a number of balls are drawn and set in motion, and the program simulates them colliding and bouncing off the walls and each other. Here's the simulation. Each ball is initially given a random position, direction, and a constant starting velocity. For simplicity, a ball's mass is simply equal to its radius. The velocity vectors are stored as (x,y) instead of polar coordinates to make the calculations simpler and the simulation faster, but this apparently has unintended consequences. In the simulation linked above, I'm starting with ten balls, and each ball has an initial velocity magnitude of 3, so the total initial "speed" of the system should be 30 ( 10 3). On each frame, I calculate the total speed of all the balls and read it out in a form field, and with uniform balls of size 10, the total speed seems to stay a few units under 30. The same is true of the min and max radius are decreased so all the balls are size 5, or increased to 20 the total speed stays relatively uniform. However, interesting things happen when the balls vary in size. If the minRadius is changed to 5 and maxRadius to 15, for example, you'll notice that the total speed of the system starts climbing over time. The bigger the difference, the faster the speed grows out of control. SO my first guess is that I screwed up the physics, but I can't figure out how. My other guess is that this is caused by accumulating floating point error, but it's interesting that it only grows upwards, and never towards zero. Also, it does seem to have a limit while it constantly fluctuates, it seems to be capped at some value related to the delta between the minimum and maximum ball size. My question is really to understand why this is happening? Did I just screw up something simple, or is something more sinister going on? |
6 | GGX specular BRDF is way over 1! Now, the classic Torrance derivation for roughened surfaces which Cook took into vectorized form yields the familiar parametrization of a specular BRDF where we have the NDF which decides how much perturbation is around the average normal direction of the macrosurface. For example, in the isotropic GGX version, an alpha value is used to modulate just how rough the surface is or just how much specular reflection a partical halfdirection yields from the microsurface normal. Then there's the geometry term which is, numerically, a protective term from the classic denominator of dot(n,v) dot(n,l) which can tend to zero and the whole term to infinity. It also has a more physically intuitive side rendered irrelevant by the sheer horror of division by zero. And there's the Fresnel term, the least threatening of all of them. Basically, it's DGF (4(n.v)(n.l)). And if any of these terms fail, it goes to hell. Hence, all of these terms have normalizing terms which force them in the 0,1 range. Unfortunately, the one I was studying from Epic does not converge give in to the normalization and some values at grazing angles get frustratingly high. The BRDF is the ratio between the outgoing radiance and the incoming irradiance. Anything beyond 1 is weird to me. But 477.43 is... Well... I've double checked everything, the math is a direct match. And yet... Any ideas? |
6 | Cloth tool and Skeletal Bone Weight Paints in Unreal Engine Just a quick question I've got my 3rd person rigged and skinned, but I have some hanging fabric around the characters waist which drapes down to the characters legs. Should this fabric be weighted so that it is affected by the characters legs as they are animated, or just the bones around the waist area? My thinking is that I don't want the cloth to be affected by the legs, as the cloth simulation will take care of that for me. Instead the aim should just be to make the cloth orientate with the bones in the waist area, mostly quot spine quot and quot spine1 quot . As such I should just skin the cloth to the lower spine bones, and ignore the legs. If I am incorrect, I'd appreciate any correction, and my apologies for any incorrect terminology, I am still learning. Cheers! |
6 | Apply force to a specific point on a rigid body In unity I have a rigid body object and would like to apply force to a specific point. For example say I had a cube, I want to hit just the top right corner so it spins as a result. One idea I had considered is spawn a small sphere and fire it at it, then destroy the sphere. But is there a way to just apply the force? |
6 | Run a physics simulation on both client and server? I'm implementing a multiplayer asteroids clone to learn about client server network architecture in games. I have spent time reading GafferOnGames and Valve's publications on their client server tech. I am having trouble with two concepts. Currently I have an authoritative game server simulating physics with box2d and sending out the state of the world to clients about 20 times per second. Each client keeps track of the last few snapshots it received and lerps between two states to smooth out the movement of sprites. However it's not that smooth. It can be smooth for a while, then jerky a bit, then back to smooth, etc. I have tried both TCP and UDP, both are about the same. Any idea what my problem might be? (Note I implemented this for single player first, and the sprite movement is perfectly smooth at 60fps when updating the physics world only 20 times per second). In order to solve the first problem I thought maybe the client should run a box2d simulation as well and just update the positions of its sprites to match the server snapshots when they don't match. I thought this might be smoother since my single player implementation is smooth. Is this a good idea? Even if it won't fix the above problem, is it necessary for client side prediction? For example, if a player attempts to move their ship, how will they know if they hit an asteroid, wall, or enemy ship without a physics simulation? It seems like their ship would appear to pass through the object it should collide with before they receive a snapshot from the server that says they hit the object. Thanks! |
6 | How can I predict player to projectile collisions in Box2D? I'm making a real time shooting game with Box2D as the physics engine. The gameplay is mostly about trajectory, like Angry Birds. I want to make a slow motion effect and move camera to the player when he's killed, but the effect should start when the stone is still in the air, before the collision actually happens. The magnitude of damage is only calculated at collision, based on impulse. Because it's a real time game, the player must be able to move their character's physics body without lag. How can I predict their death? Is it even possible? I could raycast, but what if another object moves to block its path? |
6 | add physics to a group or container body in phaser I'm developing a HTML5 Phaser game. In this game I do have a Group which I would like to behavior as a physics body (arcade physics). It is a character with a lot of moving parts (sprites) inside this group. In this case the group acts like a container for the sprites. However I only able do add physics behavior to a sprite. game.physics.arcade.enable(mySprite) works good! Doing the same to a group does not works. it only add physics to children sprites game.physics.arcade.enable(myroup) does no works myGroup.body.(...) body is undefined I would like to create a "virtual" body to this group, mannually set dimensions for it (body.setSize) and add all my sprites inside it. Is that possible in any another way? |
6 | Smooth jumping in 2D platformers I have a very simple 2D game, similar to old school Mario or Metroid. I'm having a lot of trouble figuring out the proper way to handle player jumping. I've tried several different methods. The first method being that as soon as the player presses the space bar, his position on the Y Axis is automatically updated so that he is now 50 pixels higher. This didn't work, because his player model immediately jumped up instead of going for that smooth up down look. The second method I tried was using a Timer. With this, once the player pressed the space bar, his position on the Y Axis would be incremented every x milliseconds. This also didn't work, for the exact same reason that the first way didn't work. It shot straight up without looking smooth. The last method I tried was a resemblance of my movement on the X Axis. Instead of waiting for player input, the Y Axis is constantly being added, but when the player isn't jumping, the yVelocity 0. When input does come in, an amount is added yVelocity and the player jumps up. I didn't expect this to work, obviously, but it looked better. So how do you apply jumping correctly? This is something that I've been struggling with for a while, and I just want to get it right. Please don't confuse this question like this question, as they're both different. I need an efficient way to handle jumping so that he looks smooth (as in one motion) going up and down. I can make his falling look good, just not the going up part. Can anybody explain to me how they make jumping look good? Note I wrote this question without code because I want a general description of how one might do it. If you do need code or extra details, or anything to understand the question, I'll be happy to add any extra details that you might need. |
6 | Box2D Love2D (Lua) Assertion fail with polygon meshes When I try to create a triangle collider for my game it sometimes leads to an assertion fail. I use the physics engine that comes with love2d (Box2D). That's the error message that appears when the assertion fails love modules physics box2d Source Collision Shapes b2PolygonShape.cpp 85 b2Vec2 ComputeCentroid(const b2Vec2 , int32) Assertion area gt 1.19209289550781250000e 7F' failed. Here's an example of a triangle that doesn't cause the error (represented by a table with 3 points) 258,451 , 740,767 , 284,597 And this one leads to a crash 258,450 , 222,569 , 306,723 The bodies of both shapes lie at 0, 0 (upper left corner of the screen) Does anyone know a possible reason and or solution for the problem? Edit I'm not allowed to answer my question right now for some reason so I'll post the answer here before I've forgotten it In Box2D, the order of placement of vertices seems to play an important role, since I was able to avoid the crash with the "problematic" triangle in my example from my question just by placing the first vertex between the second and the third one. Maybe I'll repost the answer when I'm able to provide more information (and am also allowed to do so) |
6 | PhysX Revolute joint around unit vector I'm using a right handed coordinate system with (0,0, 1) forward, (1,0,0) right and (0,1,0) up. PhysX version is 3.3.0. I have a unit vector which represents the axis around which my actor is supposed to be able to rotate, (0,1,0). The problem is, if I build a quaternion rotation from that vector, like so physx PxQuat q (0, physx PxVec3(0, 1, 0)) and use that for the joint, the actor will actually rotate around the direction of the rotation around the axis http youtu.be pXMlRRBVOpc However, what I want is this http youtu.be MlBx hC1Z9Q In the second case I used (0,0,1) as axis and 90 degree as rotation and used that to build the quaternion. So, how can I use my axis (0,1,0) and actually get the rotation as shown in the second video? |
6 | How do you apply relativistic physics to a 4x strategy game? I had the big idea of trying to create a hard science fiction 4X strategy game (with the obvious space setting), which is supposed to simulate a realistic way of creating interstellar societies while simulating real life physics as well. The problem is how do I apply Einstein's relativistic equations into the game? I will make a separate series of questions for other issues, such as applying Keplerian planetary movement and Newtonian combat physics. Do note the game is being made in C and in Unity. Be warned I am trying to simulate special relativity, not general relativity quite yet. That I can try in a different game. |
6 | Reimplemented steering seek behavior from PyGame to L VE is much slower than original I'm learning about steering behaviors and watched this nice explanation tutorial https www.youtube.com watch?v g1jo qsO5c4 amp feature youtu.be with the source code available at https github.com kidscancode gamedev blob master tutorials examples steering part01.py. The example app is written in python and PyGame and behaves like The main code parts of it are MAX SPEED 5 MAX FORCE 0.1 def seek(self, target) self.desired (target self.pos).normalize() MAX SPEED steer (self.desired self.vel) if steer.length() gt MAX FORCE steer.scale to length(MAX FORCE) return steer def update(self) self.acc self.seek(pg.mouse.get pos()) self.vel self.acc if self.vel.length() gt MAX SPEED self.vel.scale to length(MAX SPEED) self.pos self.vel ... I tried to reimplement this example in lua with Love2d framework and HUMP vector utility, source code is available at https github.com voronianski on games sandbox blob master src steering seek love2d main.lua. The code is pretty similar with the same constant values of MAX FORCE and MAX SPEED function Mob new () ... self.maxVelocity 5 a.k.a MAX SPEED self.maxSeekForce 0.1 a.k.a MAX FORCE ... end function Mob seek (target) self.desired (target self.pos) self.desired normalizeInplace() self.desired self.desired self.maxVelocity local steer (self.desired self.vel) if steer len() gt self.maxSeekForce then steer steer trimmed(self.maxSeekForce) end return steer end function Mob update (dt) self.acc self seek(vector(love.mouse.getPosition())) self.vel self.vel self.acc dt if self.vel len() gt self.maxVelocity then self.vel self.vel trimmed(self.maxVelocity) end self.pos self.pos self.vel dt ... end But behavior is different. Square is much more slower in lua implementation though the values are the same What could be a problem? Or what is the difference that I couldn't notice? |
6 | Why doesn't this 2d physics calculation yield the desired jump height? I found a formula for gravity and jumping in this article http error454.com 2013 10 23 platformer physics 101 and the 3 fundamental equations of platformers I implemented this formula and proceeded to do some test calculations, but they yield incorrect results. I expected the outcome to be 4, but the test resulted in 3.8. What am I doing wrong? How do I get the number 4? float deltaTime 1f 50f float maxJumpHeight 4 float timeToApex 0.44f float gravity (2 maxJumpHeight) (timeToApex timeToApex) float jumpHeight 4 float jumpVelocity (float)Math.Sqrt(2 gravity jumpHeight) float velocity jumpVelocity float position 0 while (velocity lt 0) velocity gravity deltaTime position velocity deltaTime Console.WriteLine("Position 0 ", position) |
6 | Tracing a 2d path through multiple gravity fields For a projectile starting at origin O, an initial velocity V, and several stationary planets P n , how would I pre calculate and store the path it would take without actually stepping through each frame along the curve? I have some idea of how to do this for a single gravity source (conic section, parametric curves), but how do you blend multiple forces, and thus multiple curves, together? The idea is to give the player some idea of the trajectory their shot will take, so it doesn't need to reflect the actual path exactly, but the closer the better. |
6 | Looking for very simple implicit integration example I am trying to design a robust cloth system. I have no problem at all simulating things like that using forward integration such as euler, midpoint, runge kutta, verlet, etc. However, I just can't wrap my head around implicit methods. I don't understand how you formulate the equations in linear algebra terms. I'd really like to see a VERY simple tutorial, and an actual example of how to construct the equations, and then solve for a very simple system (for example, 3 particles connected by 3 springs). I looked into David Baraff's Large Steps in Cloth Simulation, and I can kind of follow it, but going from equations to code is a weak spot of mine. I can use a package like eigen to solve, but I'd also really like to see some code for something like conjugate gradient descent. I don't care about efficiency at the moment, I just want to be able to clearly understand what's going on. Thanks |
6 | How to achieve realistic fake physics? In my opinion, games that are most entertaining to watch and play implement fake physics, the difficult issue is how to implement the fake physics and still allow it to appear realistic. Most popular car driving games implement this really well. Question Anyone has any tips or know of anywhere I can learn more about how these are implemented? Long Story For example, Need For Speed is entertaining when the player car crashes into the computer car, but it would not be fun if we land off the track each time the player collide. In the game, it is obvious that some game logic is in place to steer or land the player car upright, face correct direction and on track most of the time even after a massive collisions. The game instead causes the computer car to suffer heavier damages like flying of the screen after many spins etc to enhance effects. As another example, suppose at a time instance, a speeding player car is driving at the close rear left of a computer car and real physics dictates in the next time instance the player will definitely bump into the computer and lose speed and control. Then at this point, the player could steer right to avoid the car, or steer left to bump into its rear. In an entertaining game, we may still want the player to avoid the front car completely if he steers away and experience an exciting near miss. In NFS, this experience appears to be implmented in a few ways such as player auto steer avoidance, scraping pass and rebound to right of computer, computer car steer away to avoid, computer gets hit but lose control and spin off track to give way to player. On the other hand, it the player steers to engage in a collision, we want to add excitement to spin the computer very badly but still keep the player on track with a good speed. In NFS, these fake collisions and steering are not easily noticeable as they feel very realistic even though if we study them closely, it looks almost like the are scripted. One method I have tried is to determine the final state of collision and then compute the path backwards. But this only ensures the car is in a desired final state, does not address the realism. |
6 | Bullet Physics Applying a force at the point of collision Suppose I want to simulate some kind of gripper with two "fingers" (such as pair of pliers, or two fingered robot hand), picking up an object from the ground. Both the gripper and the object are dynamic rigid bodies. I want to start with the object roughly in the centre of the gripper, and then move the two fingers towards the object, to determine the point at which they make contact with the object's surface. Then, I want to apply a certain force from the fingers onto the object, before finally lifting the fingers (and hence the object) upwards. Is there any simple way to achieve this just by treating the two fingers as two individual rigid bodies? I want to just move the fingers towards the object to find the point of collision so can I treat them as kinematic objects (with zero mass so they don't fall under gravity, which is what I want), and move them manually by slowly changing the pose of each finger over time? But how will I know at what point the fingers and object collide, so that I should stop moving the fingers and start applying a force? Thank you! |
6 | How to resolve multiple simultaneous ball collisions in a pool game? I'm trying to simulate a break shot in billiards (1 ball hits a pyramid of 15 balls). The formula for 2D ball collision works correctly in my game. But when it is applied to the break shot, the result doesn't look realistic. (Only the 2 balls in the corners of the pyramid move, but the rest stays in place). The problem is that because 15 balls are touching each other, there is an "infinite" number of simultaneous collisions following the first one. What algorithm or formula can be used to resolve that? |
6 | Why is the MaskBit maxed out Hi there for some reason the maskbit of my b2FixtureDef is being maxxed out and im not sure why Here is the declaration of the items that are used in the game enum PhysicBits PB NONE 0x0000, PB PLAYER 0x0001, PB PLATFORM 0x0002 Basically what i want is the player to run along a surface is not slow down (i set platform amp player friction to 0.0f) I then setup my Contact Listener to print out the connections (currently only have 1 platform and 1 player) Player Fixture Def b2FixtureDef fixtureDef fixtureDef.shape amp groundBox fixtureDef.density 1.0f fixtureDef.friction 0.0f fixtureDef.filter.categoryBits PB PLAYER fixtureDef.filter.maskBits PB PLATFORM Platform Fixture Def b2FixtureDef fixtureDef fixtureDef.shape amp groundBox fixtureDef.density 1.0f fixtureDef.friction 0.0f fixtureDef.filter.categoryBits PB PLATFORM fixtureDef.filter.maskBits PB PLAYER Now correct me if im wrong but these are saying the following Player Collides with Platform Platform Collides with Player Here is the printout of the fixtures colliding with each other lt Indicates new Contact Platform ContactA 2 MaskA 1 Player ContactB 1 MaskB 2 lt Indicates new Contact Platform ContactA 2 MaskA 1 Player ContactB 1 MaskB 65535 lt Indicates new Contact Platform ContactA 1 MaskA 65535 Player ContactB 1 MaskB 65535 Here is where i am confused. On the second amp third contact the player maskBit is set to 65535 when it should be 2 and there are 3 contacts when i am sure at most there should only be 2. I've been trying to figure this out for hours and i can't understand why it is doing this. I would be very grateful is someone could shine some light on this for me UPDATE I printed out the class of the contacting objects. For some reason it seems to do the following First Contact Correct Result. Second Contact Player b2Fixture Obtains a new maskBit. Third Contact Platform b2Fixture appears to be set to the same as the Player b2Fixture. It would seem I have a memory race condition i think |
6 | Game physics of tearing apart For a game I'm programming I'm looking for a kind of realistic mechanic for simulating the tearing apart of objects. Let me explain I have a given point p in a 2 dimensional space (possible later also more dimensions so a solution should be scalable, which i assume is not the problem) and I have a number of forces f1, f2, ..., fn acting on this point p. So normally this point moves over time according to the combination of this forces. But now I'm looking for a kind of realistic mechanic that if forces vary strongly the point objects gets split up in two points objects that move in different directions. Here a simple visual example three quot similar quot forces resulting in one single force (the point will move according to this single vector) three forces that quot tear quot the point apart and result in two vectors (point will be split up in two new points that move according two the respective vector) I amuse we need two give the point some kind of inner force, that defines how easy it is to tear the point apart? By kind of realistic I mean something that doesn't need to be extremely realistic according to the real world physics but something that would fell kind of real in a video game. So an additional benefit would be that it can be easily computed. |
6 | What physics engine support force fields and bodies represented as points? I need a game engine that supports force fields in 2d or 3d, but suitable for 2d calculations, like bullet. Each body I want to simulate is represented as a set of points. Each point has positive mass and can accept force. Force field is updated every tick. Engine should accept force applied to every point and return point speed values and coordinates. Each body made of particles should move as a whole thing in result, relative position of particles must persist, hence this is a rigid body. If engine does not support setting body as a set of points it should allow setting density function, or some other means to let have non uniform density. Is there any that can do that, preferably cross platform. |
6 | Voxel blocks world physic I'm making a game like Minecraft. I have a world made of blocks and I'm trying to implement a basic physic system that applies gravity and checks entities colliding with the blocks of the world. I tried using Bresenham's algorithm, on player move, to get all blocks between, and then get the first solid and set the player on colliding position. That works well if the player is a point, but if it's a complex AABB and the block too, it becomes difficult. Is there a simple way to make physic in a voxel world like Minecraft? |
6 | Center of Mass for Convex shape in 3D For an arbitrary convex shape in 3D, how can I calculate its center of gravity? I have face normals, and the vertices for each face. Ocelot No, it most certainly is not the average of the vertices, as demonstrated in this simple 2D case. The average of coordinates is in top of shape, whereas the C.o.M. is in the bottom half. |
6 | Making a parent system with euler angles (gimbal lock problem) I have a system where objects can be connected to each other as the parent rotates the child objects will rotate too and child objects themself can rotate too. The system is already working, however, I am doing it with rotation matrices. I want to dynamically simulate angular physics and for that, I would need the angular velocity for which I thought the direct and easiest way would be to get the difference of the euler angles. I am still a beginner with those rotation maths like matrices, quaternions etc. The problem is that the rotation of the children would be local and currently I am just adding the euler angle values (which works fine if I only rotate around one axis). So when I rotate a child on the x axis by 90 degrees and then rotate the parent on the y or z axis the system breaks (y and z should be swapped in this scenario with 90 degrees x rotation) As far as I have understood it the problem could be explained with quot gimbal lock quot . Is there a way to calculate the local euler angles? Or is there in general a better way to achieve what I am trying to do here? I have heard that quaternions also don't save 360 degrees, so that would be also a problem for angular velocity. |
6 | Performing movement per game tick Assume we have a player on a map, whereby the grid is represented as a floating point. When a player is moving, they have an x and y velocity. How to do you properly apply their movement each gametic? By that I mean do you keep nudging the player forward by one map unit and repeat that by the velocity? Where is that fine line where I say "we don't go any smaller movements than this like 0.5, or 0.25, etc" Further, is there a way to optimize this to be able to make movement fast computationally? I thought of having some kind of blocks where you can quickly check if you'd intersect anything and make some optimizations, but I have no idea if this is good, bad, or how it should be done. Update Suppose you have a projectile traveling 100 map units North, and it would collide with an object 50 map units North of it. In the period of one world 'ticking', would you just halt it in a dead on collision (assuming the line is impassible), or would you detect a collision and then do something after it since that remaining 100 map unit velocity (like maybe if it's on an angle then cancel its Northward momentum and continue trying to move it to the East West. |
6 | How to reduce the time it takes to speed up an object? I have a body that I am applying a force to every step. However, I it takes a significant amount of time for it to speed up, which I do not want. Is there some value I can adjust to help with this? |
6 | Adding gravity to arrival steering behavior I trying to write an autopilot for the classic Lunar Lander or its clones. According to this paper, the arrival behavior is exactly what I need for a soft landing. In this example, it accelerates at max speed until it's near the target and decreases near the target to zero. Adding gravity and a engine to decelerate makes this a lot more complicated, at least for me since I couldn't wrap my head around the concept for the past few hours. Currently my spaceship moves in the right direction but doesn't counter gravity and just throttles the engine, crashing near the target. I know my current position, velocity and the gravity is constant. I need to output thrust levels (0 4) with a 90 to 90 angle. Can you give me some pointers as to how I could incorporate gravity into this steering behavior? |
6 | Can I use physics in Isometric map based games? I am trying to use physics in my game which is an isometric map based strategy game that the player deals with a city full of buildings, roads and people in it. I am writing the game with Swift and SpriteKit technology. (the following picture shows a snapshot of my game) MY GAME I like to use Spritekit's physics library so I would be able to simulate car accidents and preventing them to go throw the buildings and other kind of stuff that physics could provide. I am familiar with Physics and I have enough experience with Bullet and I can write a 3D game using OpenGL ES and physics, but I haven't really used physics in 2D isometric map games. I have also wrote a 2d physic game that was really 2d (an endless runner) which was actually a sample of a book but as you can see in the following picture the gravity vector is the Y axis and every thing is pretty easy. Here is the gravity vector that is used to create the game at the following picture. self.physicsWorld.gravity CGVectorMake(0, 9.8) Someone Elses Game, Book Sample Book Name iOS 7 Game Development Author Dmitry Volevodz You may find the book Here However, in an isometric map game you can't just set and assign the Y axis as a gravity vector. since the method which sets the gravity vector accepts two arguments it is a big hope that I can use physics in my isometric map games. For example something like this I Say!!! As I am still using a cartesian coordinate system (perpendicular axis) X and Y axis make a 90 degree angle and if I need to project the gravity quantity over the X and Y axis it would be gCos(45),gSin(45) I haven't tested it yet. self.physicsWorld.gravity CGVectorMake( 9.8 0.707, 9.8 0.707) May you please help me on setting the gravity vector and how should I define the moving objects like cars and humans and the static ones like buildings any other tips on modelling physics in isometric map are also welcome and appreciated. The main question is is it really possible to use physics in an isometric map based games? |
6 | Fixed timestep without physics? I read Gaffer's Fix Your Timestep article many years ago, and have since had the impression that game code should have a fixed timestep, with only non gameplay related tasks outside of that in the main loop. However, I recently reread the article, along with several others, and realized the emphasis is on physics. Which makes sense, but now I'm wondering if it only applies to physics. What about games which don't use a real physics simulation? People talk about 60fps games, doesn't that imply a fixed timestep? What about multiplayer where you have regular updates to and from the server? The only alternative I know of is variable rate with time delta, but that sounds like it wouldn't be any better, and less exact. What method is typically used? |
6 | Who know how to implement the 2D bone animation showed in the game? I wonder how do they implement the bone animation in the flash game http www.foddy.net athletics.swf Do you know any study materials which I can start to learn 2D bone system from? I just implemented a avatar system by compose multiple bitmaps in each frame(similar with maple story), but some guys tell me that, a bone system can save more art resources, so I want to learn some thing about that. |
6 | 2D bouncing ball simulation angular velocity How does angular velocity of a ball affects it's speed after a bounce? I'm trying to simulate 2D bouncing ball physics. I've found a nice solution how to calculate ball's velocity after a bounce mVelocity.x 1 mi (e 1) mVelocity.y e where mVelocity.x is a component of ball's velocity parallel to the "surface" of a bounce, mi is coefficient of friction, e lt 1 representsthe energy loss during the impact. It's looks quite realistic, however I'd like to calculate angular velocity as well and I assume it's also affecting how the ball actually bounces. I tried to achieve it using matrix found on wolfram site http demonstrations.wolfram.com BouncingASuperball (it's in the bottom of the page), but its implementation doesn't look realistic at all, ball is acting very wierdly. How can I calculate it? |
6 | How do I implement friction in a billiards game? I'm having trouble implementing friction in a billiards game. Currently, the ball only slows on collision with the edges, but I also want some friction with the background. How can I implement friction? (I'm using PhysicsJS.) |
6 | Can I use physics in Isometric map based games? I am trying to use physics in my game which is an isometric map based strategy game that the player deals with a city full of buildings, roads and people in it. I am writing the game with Swift and SpriteKit technology. (the following picture shows a snapshot of my game) MY GAME I like to use Spritekit's physics library so I would be able to simulate car accidents and preventing them to go throw the buildings and other kind of stuff that physics could provide. I am familiar with Physics and I have enough experience with Bullet and I can write a 3D game using OpenGL ES and physics, but I haven't really used physics in 2D isometric map games. I have also wrote a 2d physic game that was really 2d (an endless runner) which was actually a sample of a book but as you can see in the following picture the gravity vector is the Y axis and every thing is pretty easy. Here is the gravity vector that is used to create the game at the following picture. self.physicsWorld.gravity CGVectorMake(0, 9.8) Someone Elses Game, Book Sample Book Name iOS 7 Game Development Author Dmitry Volevodz You may find the book Here However, in an isometric map game you can't just set and assign the Y axis as a gravity vector. since the method which sets the gravity vector accepts two arguments it is a big hope that I can use physics in my isometric map games. For example something like this I Say!!! As I am still using a cartesian coordinate system (perpendicular axis) X and Y axis make a 90 degree angle and if I need to project the gravity quantity over the X and Y axis it would be gCos(45),gSin(45) I haven't tested it yet. self.physicsWorld.gravity CGVectorMake( 9.8 0.707, 9.8 0.707) May you please help me on setting the gravity vector and how should I define the moving objects like cars and humans and the static ones like buildings any other tips on modelling physics in isometric map are also welcome and appreciated. The main question is is it really possible to use physics in an isometric map based games? |
6 | Verlet collision with impulse preservation I came across this article, recently, that presented a technique for impulse preservation with position based verlet integration. What was interesting was that the integration steps are seemingly done differently from typical position based verlet schemes, as well as the ordering of the integration step and collision resolutions. Specifically, the typical verlet position integrator is newPosition 2 position oldPosition acceleration timeStepSquared oldPosition position position newPosition DoConstraints() Where the article has position acceleration timeStepSquared DoConstraints() newPosition position 2 oldPosition oldPosition position position newPosition Which ignoring constraints for a moment works out to be newPosition 2 position oldPosition 2 acceleration timeStepSquared oldPosition position acceleration timeStepSquared position newPosition Which is different in a term of acceleration timeStepSquared. I haven't quite convinced myself that those terms cancel out through the iteration, as the prior acceleration timeStepSquared term may not be the same as the current one. Could someone explain the reasoning for this, and if indeed it makes sense? |
6 | How to calculate collision normal between two AxisAlignedBox's? I'm writing a physics simulation in Ogre3D and I'm trying to figure out how to calculate the collision normal between two Ogre AxisAlignedBox's. I am checking for collisions using the "intersects" function then calculating the collision normals as below, but I am almost certain that this is where I am going wrong as my collisions are very unpredictable Ogre AxisAlignedBox intersection boxA.intersection(boxB) Vector firstCollisionNorm boxA.getCenter() intersection.getCenter() Vector secondCollisionNorm boxB.getCenter() intersection.getCenter() After this, I am normalizing the collision normals, calculating the impulse magnitude using dot product, mass and relative velocity, then I multiply the collision normals by the magnitude to get the final impulse force vector, which is added to my current force vector as "impulseForce deltaTime" for the next step of euler intergration. If anyone could help me out I would greatly appreciate it! Thanks |
6 | How to make a character in a Box2D world jump faster? I have a question about using Box2D to simulate a physics platformer. I manage to make the character move to the right and left, and jumping as well. However, jumping seems extremely slow when compared to most tile based platformers. Is there a way to speed up the jumping and falling of the player? I of course know from my basic physics lessons that 'heavier' objects don't fall faster in the real world, but is there a way to simulate this in Box2D? |
6 | In Godot, how to make a Kinematic body affectable by rigid bodies? Background Info I'm currently following the FPS tutorial from the official site. By the end of Part 1, there is a Player object implemented as a KinematicBody and controlled by player input, and a few cubic blocks scattered around, implemented as RigidBodies. The KinematicBody is moved with the move and slide function that takes static colliders into account, so the player is able to stand on the floor and bump into walls. However, the player can't bump into or stand on the cubes. If you attempt to jump onto a cube, it will slide from under you. If you try to push a cube into a wall, it will glitch around a little, then slide away, without even slowing you down. The cubes have no power to stop the KinematicBody from moving through them. Question How can I change the behaviour to make it possible for a KinematicBody to stand on a RigidBody? |
6 | How to disable static friction in Box2D? I'm making a 2D platformer. One of the issues is that when the character hits the ground, there's an initial pause and then the character finally slows down to a halt. I believe the initial pause is because the coefficient of static friction is higher than the coefficient of kinetic friction. How can I set the coefficients to be equal or disable static friction? |
6 | How can I implement large moving "colossus" characters that also act as environmental objects? I'm curious how enormous characters that act both as entities and environments are implemented. I'm thinking of characters like in Shadow of the Colossus which move, but which the player can also move on. It seems these objects would be created as characters, rigged like any character would be with their various animations, but they would also need to be usual physical surfaces that we can walk on. Considering the way characters are handled compared to how static environment is handled physically in most game engines, this could prove problematic, and added to that is the problem of size. So, generalising over engine details (but assuming you have a generic physics character engine, e.g. Unity Unreal) what approach should be taken? Also, screenshot As you can see in this screenshot, the colossus is really big, and the player can walk on it and climb on some parts of it (hairs mostly) And a video of a boss fight here which really shows what this gameplay is all about |
6 | Typical Maximum steering angle of a real car I'm building a car sim in Unity3D. I'm trying to set the properties of the car to be as realistic as possible. I can't seem to get a straight answer on Google so I thought of asking here. What is the typical maximum steering angle of a normal passenger car ? |
6 | Moving object through nodes in Quadtree I'm working on my own quadtree for use in games for physics (collision detection to be exact) but am unable to move an object from one node to another node. What I'm doing is if some object is to be moved, I'm deleting it from its old position and adding a new object (with same property, such as width and height) to the new position. Is my approach correct or is there any other optimized process to do same? The problem I'm facing is that if I move an object from node 0 to node 3 (both node being children of, for ex., root node) the root node container(I'm using std vector) gets the object but it is not updated in the node 3's container. Any solution to my problem? Though would be happy to try some other method too. Thanks. |
6 | Orbital mechanics orbit as a function of time. Universal variable formulation? I am trying to model a two dimensional orbit for a two body Kepler problem but have gotten stuck when introducing the time variable. For a satellite with known semi major axis (a), eccentricity (e), and true anomaly (theta), I have r a (1 e 2) (1 e cos(theta)) How can I calculate theta as a function of time using the Wiki suggested Universal variable formulation method? I have no idea how to implement (am using Python but any algorithm advice much appreciated!) Alternatively, how do I calculate r as a function of time? Note All other orbital elements and masses are available. Also I am trying to come up with a general solution for elliptical, hyperbolic and parabolic orbits. Cheers! |
6 | Objects are stumbling in place continuously. How to fix that? I have a nasty problem with my physics engine. Objects sometimes just jump in place, or roll left and right. Main game loop works in that manner Every living object is updated (it changes velocity, the logic is different for each object) Engine computes collisions using objects' positions and velocities and resolves them. Imagine that we have a grenade positioned at one pixel above ground, with zero speed, and the gravity is 1 px tick 2. Normal bounce coefficient is 0.5, so an object will bounce with half speed. According to the algorithm Object's controller adds gravity to its velocity, so now v 1. Engine moves object to y 0, no collisions happen. Velocity is changed to 2 by the controller. Engine tries to move the object, the collision happens immediately, v is set to 1, and object moves to y 1. Velocity is changed to 0 by the controller. The object remains in place. Initial conditions has reproduced. The object will bounce forever with a period of 3 ticks. These situations vary, but they all are caused by discrete nature of the engine described above. This bug was in every version of my game. Objects may vary in shape and size, and the terrain is destructible Worms like. I use my own engine that uses swept collision detection customized to work with small and fast objects, never letting them go through impassable object unless they were spawned inside, and the only acceptable option for me is to modify it. One thing that I have in mind that I can detect if object had very low speed for some time, make it "immobile" and call different controller functions depending on "immobile" flag. It's an ugly solution though, because the complexity of my logic will increase. Also, when a round object stands on two points and we remove one, it will not fall. So this approach is wrong at all I guess. What is the right approach to fix that? |
6 | Physics in carrom like game using cocos2d Box2D I am working on carrom like game using cocos2d Box2D. I set world gravity(0,0), want gravity in z axis. I set following values for coin and striker body Coin body (circle with radius 15 PTM RATIO) density 20.0f friction 0.4f restitution 0.6f Striker body (circle with radius 15 PTM RATIO) density 25.0f friction 0.6f restitution 0.3f Output is not smooth. When I apply ApplyLinearImpulse(force,position) the coin movement looks like floating in the air takes too much time to stop. What values for coin and striker make it look like real carrom? |
6 | Check gap in 3d environnement I am in a 3d environnement, when I jump, i'm calculating the hitPoint of the end jump. I want to know when I jump, if there is a GAP between my initial point, and the end point. But I don't want to set any trigger in the Level Design... My Initial Idea is to do Raycast each 5 6 steps, but I wonder if this is too much cost effective. MayBe it isn't ? |
6 | Implementing proportional navigation in 3D Good afternoon guys, a N ' V is the formula for the commanded acceleration required to hit the target, where N is the proportionality constant, ' is the change in line of sight and V is the closing velocity. Data I natively have x,y,z position of both missile and target vx,vy,vz velocity vector of both missile and target x,y,z vector which points from missile to target and opposite This is set by me but still maximum speed of missile. Data I can get with some calculations Vertical angle between missile and target (and opposite) Horizontal angle between missile and target (and the other way around). That's the reference system of the game ' or the derivative with respect to time of the Line of Sight it's a concept I really didn't understand... its unit should be, in theory, Hz or (s 1) since m s 2 ' m s ' 1 s V should be pretty easy to calculate V v(missile) v(target) OR Vx (v(missile) v(target)) cos (x0y) Vy (v(missile) v(target)) sin (y0z) Vz (v(missile) v(target)) cos (y0z) N well it's a scalar number, usually 3. The computed acceleration will then be passed to a RK4 integrator which will move the interceptor towards its target. To steer the missile, I will simply change its velocity vector at every update (every 1 60th of a second) and its orientation accordingly. For example if the missile has a velocity of 0,100,0 , he's going 100 m s due y axis. If at the next frame it should slightly turn right, then he'll be going to have a velocity of 10,99,0 and so on. That's the only thing left to finish off my little thesis and unfortunately I'm stuck here. In the meantime, thank you very much! Here's a video I made, but it doesn't still actually use the Proportional Navigation law it checks if the missile is "aligned" to its target and eventually correct its route. That's my actual code pastebin That's what i've come up with but sadly doesn't work as expected params " n"," missile"," target" private " a" vm velocity missile rm getPosASLVisual missile vt velocity target rt getPosASLVisual target vr vt vectorDiff vm r rt vectorDiff rm omega ( r vectorCrossProduct vr) vectorMultiply (1 ( r vectorDotProduct r)) a ( vr vectorCrossProduct omega) vectorMultiply n a Similar questions Finding the components of Proportional Navigation in 2D |
6 | Why not derive velocity from position updates in games? Is there a reason why retrieving velocity of a 3d object in a game engine vs deriving it from position updates is preferable? I am currently polling position at every step and deriving current velocity, however, there is also a "get velocity" option. I already need position but I'm wondering if the velocity in the game engine is preferable for some reason like it has less latency than the derivative. |
6 | Making a parent system with euler angles (gimbal lock problem) I have a system where objects can be connected to each other as the parent rotates the child objects will rotate too and child objects themself can rotate too. The system is already working, however, I am doing it with rotation matrices. I want to dynamically simulate angular physics and for that, I would need the angular velocity for which I thought the direct and easiest way would be to get the difference of the euler angles. I am still a beginner with those rotation maths like matrices, quaternions etc. The problem is that the rotation of the children would be local and currently I am just adding the euler angle values (which works fine if I only rotate around one axis). So when I rotate a child on the x axis by 90 degrees and then rotate the parent on the y or z axis the system breaks (y and z should be swapped in this scenario with 90 degrees x rotation) As far as I have understood it the problem could be explained with quot gimbal lock quot . Is there a way to calculate the local euler angles? Or is there in general a better way to achieve what I am trying to do here? I have heard that quaternions also don't save 360 degrees, so that would be also a problem for angular velocity. |
6 | Oscillating an object left and right based on it's current orientation I'm currently implementing a fire animation in HTML5 Canvas using the phone's accelerometer. Regardless of the phones orientation, the triangles for the fire move upward. So you can spin your phone around to what ever degree you wish, and the triangles will move towards the sky. My issue is trying to implement an oscillation left and right for these triangles. Before I had the accelerometer hooked up, I just applied an oscillation to the x axis and everything worked fine. Now however because the triangles are moving in what ever direction up is, I need to somehow apply the oscillation to both axis depending on what the orientation of the phone is. Could anyone help me out? I'm using JS for this. Thanks. |
6 | Maximum range of projectile fired at given force and elevation I've gone over this again and again, and my result is obviously wrong when viewed in action. Here's the initial formula I converted (first one) http en.wikipedia.org wiki Range of a projectile and here's my C code float CalculateMaximumRange() float g Physics.gravity.y float y origin.position.y float v projectileSpeed float a 45 float vSin v Mathf.Sin(a) float vCos v Mathf.Cos(a) float sqrt Mathf.Sqrt(vSin vSin 2 g y) return Mathf.Abs((vCos g) (vSin sqrt)) Does anyone see what I did wrong? |
6 | How to make bird to fly using box2d I am new to Box2D, I have set gravity to 10. How to make an object fly in space even though the gravity is 10. What are the properties I need to set to make object fly? Is there any different approach? |
6 | Looking for a peer reviewed article that details the benefits of a physics simulation within interactive media I'm hoping this is the correct place to ask this question as it is video game related and can be seen as a key ingredient in modern game development. Does anyone know of a peer reviewed article that details the benefits of incorporating a physics simulation into interactive media (such as video games)? I can find books with a few remarks in their introduction (no more than a couple of sentences) but nothing substantial. |
6 | Physics based dynamic audio generation in games I wonder if it is possible to generate audio dynamically without any (!) audio assets, using pure mathematics physics and some input values like material properties and spatial distribution of content in scene space. What I have in mind is something like a scene, with concrete floor, wooden table and glass on it. Now let's assume force pushes the glass towards the edge of table and then the glass falls onto the floor and shatters. The near realistic glass destruction itself would be possible using voxels and good physics engine, but what about the sound the glass makes while shattering? I believe there is a way to generate that sound, because physics of sound is fairly known these days, but how computationaly costy that would be? Consumer hardware or supercomputers? Do any of you know some good resources videos of such an experiment? |
6 | Using Box2D for range detection? I have two entities. One has a sword, one has a bow and arrow. When the bow entity is 100 units away, he needs to begin attacking. Likewise, when the sword entity is 10 units away, he needs to begin attacking. My idea is to create an actual physical body for collision detection and a range body (or fixture?) for range detection. However, I don't want the range body to start pushing and affecting other entities. I simply want to detect when one entity's range body collides with another entity's physical body. Is this the right thing to do and how can I do this with Box2D? |
6 | Basic Box2D collision detection I don't understand how to listen for collisions in Cocos2D Box2D. Say I have two dynamic circle bodies. One is very small and the other is relatively large. When the small circle collides w the large circle I'd like to do something (play a sound for example). What's the best way to do this? I'm currently experimenting w the TestPoint method. Something like if(largeCircleBody gt GetFixtureList() gt TestPoint(smallCirclePoint)) collision happened... play sound etc |
6 | Game Physics Implementing Normal Reaction from ground correctly I am implementing a simple side scrolling platform game. I am using the following strategy while coding the physics Gravity constantly acts on the character. When the character is touching the floor, a normal reaction is exerted by the floor. I face the following problem If the character is initially at a height, he acquires velocity in the Y direction. Thus, when he hits the floor, he falls through even though normal force is being exerted. I could fix this by setting the Y velocity to 0, and placing him above the floor if he has collided with it. But this often leads to the character getting stuck in the floor or bouncing around it. Is there a better approach ? |
6 | How can I implement smooth digging effects in a tile based game? I'm trying to make a Dig Dug styled game where you will be digging into a material. This is going to be a tile based HTML5 game and I have decided to use the Phaser framework. One way to do the digging mechanic is to break the play area into tiles and remove tiles as the player sprite collides. But I would like to have a smooth digging animation physics, so it appears that the player character "carves" out the soil as it digs through. Any tips on how I should do this? Right now I have 15x15px tiles while the player is 45x45px, this sort of fakes the smooth digging I want. Is there a better way? |
6 | Is an inertia tensor in local space always diagonal? I'm looking at the implementation of a physics engine and I observe that the inertia tensor of a rigid body, in local space coordinates, is stored as a 3 dimensional vector, rather than a 3x3 matrix, and the description says quot A vector with the three values of the diagonal 3x3 matrix quot . A diagonal matrix is one with all zero off diagonal entries. What I don't understand is why the inertia tensor in local coordinates would be diagonal? Why couldn't it have non zero off diagonal entries? |
6 | How do I figure out if a point is infront or behind my vehicle? I need to figure out whether a point is infront or behind my vehicle. I have the vector of it's position, forward direction. So far I have tried finding the vector perpendicular to its forward direction and then calculating what side of the line it is positioned on. This works fine at first. But then I realised it is only calculating around the origin. bool Car isInfront(ngl Vec2 pos) http stackoverflow.com questions 1243614 how do i calculate the normal vector of a line segment if we define dx x2 x1 and dy y2 y1, then the normals are ( dy, dx) and (dy, dx). create vector per to the direction of travel. ngl Vec2 fwdVec m carPhysics gt getForwardVec2() ngl Vec2 pos m carPhysics gt getPosVec2() ngl Vec2 dir pos fwdVec float dx dir.m x pos.m x float dy dir.m y pos.m y ngl Vec2 v1( dy, dx) ngl Vec2 v2(dy, dx) ngl Vec2 perp (v1) (v2) int turn getLeftOrRight( pos, perp) if(turn LEFT) return true else return false int Car getLeftOrRight(ngl Vec2 dir, ngl Vec2 fwd) http gamedev.stackexchange.com questions 34536 calculating angle between two vectors to steer towards a target cross product float val ( dir.m x fwd.m y) ( dir.m y fwd.m x) if(val gt 0) return LEFT else return RIGHT |
6 | Web workers for HTML5 game physics simulation? A bit related to this question. The idea is to guarantee the same physics behavior as much as possible. Would it be possible to run fixed time step physics on a web worker? The UI would update itself with different variable refresh rate. Has anyone tried such yet? |
6 | Correct order of tasks in each frame for a Physics simulation I'm playing a bit around with 2D physics. I created now some physic blocks which should collide with each other. This works fine "mostly" but sometimes one of the blocks does not react to a collision and i think that's because of my order of tasks done in each frame. At the moment it looks something like this function GameFrame() foreach physicObject do AddVelocityToPosition() DoCollisionStuff() Only for this object not to forget! AddGravitationToVelocity() end RedrawScene() Is this the correct order of tasks in each frame? |
6 | How do I calculate the motion of 2 massive bodies in space? I'm writing code simulating the 2 dimensional motion of two massive bodies with gravitational fields. The bodies' masses are known and I have a gravitational force equation. I know from that force I can get a differential equation for coordinates. I know that I once I solve this equation I will get the coordinates. I will need to make up some initial position and some initial velocity. I'd like to end up with a numeric solver for the ordinal differential equation for coordinates to get the formulas that I can write in code. Could someone break down how from laws and initial conditions we get to the formulas that calculate x and y at time t? |
6 | How can I implement smooth digging effects in a tile based game? I'm trying to make a Dig Dug styled game where you will be digging into a material. This is going to be a tile based HTML5 game and I have decided to use the Phaser framework. One way to do the digging mechanic is to break the play area into tiles and remove tiles as the player sprite collides. But I would like to have a smooth digging animation physics, so it appears that the player character "carves" out the soil as it digs through. Any tips on how I should do this? Right now I have 15x15px tiles while the player is 45x45px, this sort of fakes the smooth digging I want. Is there a better way? |
6 | How to implement friction in a physics engine based on "Advanced Character Physics" I have implemented a physics engine based on the concepts in the classic text Advanced Character Physics by Thomas Jakobsen. Friction is only discussed very briefly in the article and Jakobsen himself notes how "other and better friction models than this could and should be implemented." Generally how could one implement a believable friction model on top of the concepts from the mentioned article? And how could the found friction be translated into rotation on a circle? I do not want this question to be about my specific implementation but about how to combine Jakobsens ideas with a great friction system more generally. But here is a live demo showing the current state of my engine which does not handle friction in any way http jsfiddle.net Z7ECB embedded result Below is a picture showing and example on how collision detection could work in an engine based in the paper. In the Verlet integration the current and previous position is always stored. Based on these a new position is calculated. In every frame I calculate the distance between the circles and the lines. If this distance is less than a circles radius a collision has occurred and the circle is projected perpendicular out of the offending line according to the size of the overlap (offset on the picture). Velocity is implicit due to Verlet integration so changing position also changes the velocity. What I need to do know is to somehow determine the amount of friction on the circle and move it backwards parallel to the line in order to reduce its speed. |
6 | Oblique launch within a game I'm creating a simple game in python that will follow the same logic of DDTank and Worms. The graph is formed by characters. The buildings that will be destroyed are formed by ' ', players are ' ' and the projectile I still did not think the character. For now I did the part that draws the buildings with a random height. But I was thinking the logic of launching projectiles. I learned in physics classes some formulas for oblique launch. So wanted to know if these formulas would fit in a computer program or I would have to invent another logic? Formulas vx v0 . cos ? x vx t v0y v0 sen ? y v0y t g t 2 |
6 | Do you really have to sync Physics over the network? Let's say you want to create a 2D game where a character can shoot a bullet. You have the same code running on the Client and Server (JavaScript so it's exactly the same code). If the client and the server create the same bullet instance at the same tick X, with the same position, direction and velocity, is it safe to assume that the bullet will end on the same place on both the server and the client? Does the server need to send back the exact position at which the bullet collided, or can the client just predict that as it uses the same physics and same bullet initial data. Can the bullet hit the target on a different tick, or at a different position on the server from the client? My initial thought is that this shouldn't happen, but could this happen because of a different CPU architecture or a different JavaScript engine? |
6 | How would one generate a texture for cracks in different materials? I would want to have the ability to simulate different variables like brittleness, or other variables to get varied end results. I would mainly need to generate impact cracks, so it would need to react to different impact angles and speeds. I am using ActionScript3, but general theory answers will be helpful as well. |
6 | Collisions between sprites in SpriteKit I'm making a game in XCode using SpriteKit. The game has a player and different types of projectiles that he has to avoid. When the player collides with the projectiles, the score changes and the projectile disappears. However, when two projectiles collide, they kind of bounce away. I want to make that every time two projectiles collide, they act like nothing happened and they keep going in their original path. What should I do? Note This is not the whole code, it's just what matters. import SpriteKit struct Physics static let player UInt32 1 static let missileOne UInt32 2 static let missileTwo UInt32 3 class GameScene SKScene, SKPhysicsContactDelegate var player SKSpriteNode(imageNamed "p1.png") override func didMoveToView(view SKView) physicsWorld.contactDelegate self player.position CGPointMake(self.size.width 2, self.size.height 5) player.physicsBody SKPhysicsBody(rectangleOfSize player.size) player.physicsBody?.affectedByGravity false player.physicsBody?.dynamic false player.physicsBody?.categoryBitMask Physics.player player.physicsBody?.collisionBitMask Physics.missileOne player.physicsBody?.collisionBitMask Physics.missileTwo var missileOneTimer NSTimer.scheduledTimerWithTimeInterval(1, target self, selector Selector("SpawnMissileOne"), userInfo nil, repeats true) var missileTwoTimer NSTimer.scheduledTimerWithTimeInterval(1.2, target self, selector Selector("SpawnMissileTwo"), userInfo nil, repeats true) self.addChild(player) When contact happens func didBeginContact(contact SKPhysicsContact) var firstBody SKPhysicsBody contact.bodyA var secondBody SKPhysicsBody contact.bodyB if ((firstBody.categoryBitMask Physics.player) amp amp (secondBody.categoryBitMask Physics.missileOne)) CollisionWithMissileOne(firstBody.node as SKSpriteNode, missileOne secondBody.node as SKSpriteNode) else if ((firstBody.categoryBitMask Physics.player) amp amp (secondBody.categoryBitMask Physics.missileTwo)) CollisionWithMissileTwo(firstBody.node as SKSpriteNode, missileTwo secondBody.node as SKSpriteNode) else if ((firstBody.categoryBitMask Physics.missileOne) amp amp (secondBody.categoryBitMask Physics.missileTwo)) CollisionBetweenMissiles(firstBody.node as SKSpriteNode, missileTwo secondBody.node as SKSpriteNode) For Player and MissileOne func CollisionWithMissileOne(player SKSpriteNode, missileOne SKSpriteNode) missileOne.removeFromParent() For Player and MissileTwo func CollisionWithMissileOne(player SKSpriteNode, missileTwo SKSpriteNode) missileTwo.removeFromParent() For MissileOne and MissileTwo func CollisionBetweenMissiles(missileOne SKSpriteNode, missileTwo SKSpriteNode) ???WHAT SHOULD I CODE HERE??? |
6 | Gravity and Jumping in Clickteam Fusion 2.5 So I'm currently building a bare bones functioning game that involves simple platforming. Quite literally a box moving left and right and jumping. I'm using Clickteam Fusion 2.5, and I know there's an option to assign platforming movement to an active object, but I honestly do not enjoy implementing that feature one bit. So instead I'm opting for simply adding or subtracting from the X and Y coordinates of the player object while the left and right arrow keys are held down for side scrolling movement. However, I have yet to figure out how to use this same method for jumping and gravity. I know being able to jump would be running an event that occurs after hitting a certain key, which takes in the current Y coordinate of the player and runs it through a parabolic formula. And then gravity would simply be constantly subtracting from (or I guess in Fusion's case, adding to) the current Y value of the player object while the frame is running. So the question simply is where and how do I implement these things in order to create jumping and gravity. I figure there's a correct syntax for a parabolic formula when creating an event after "jump" is pressed, but for the life of me I can't figure it out. As for gravity, I'm completely lost. I have managed to get down stopping movement when colliding when another object so that is not an issue. Thanks and appreciation in advance. |
6 | Do two balls of different mass bounce different heights? There are two balls and the only difference between them is the mass. Both are dropped from the same height on to the floor (static object with infinite mass), would both balls bounce up to the same height, or would the heavier ball bounce higher as it enters the collision with more momentum? From my own derivation it would appear that the calculation reduces down to a simple vector reflection about the contact normal, but it doesn't feel right. Can anyone verify this? EDIT To be clearer, I am looking for a code sample of how to resolve a ball collision against a plane using a collision impulse. Does the collision impulse rely on the ball's mass when colliding with an object of infinite mass? |
6 | How to make a character jump? I am currently making a game in C using Direct X 9.0. The game remake is Donkey Kong NES. I have nearly everything completed, but I am having problems with the physics of Mario's jump. I have variables declared for the Y and X co ordinations. I was wondering if there was a simple method of doing this. I have searched high and low for an answer but the answers I have found are either irrelevant or using a different programming language such as XNA. I currently have a bool variable set to check to see if W has been pressed then that will trigger any code to make him jump. I have been messing around such as. if (jump true) Playerypos vel Playerxpos vel Which didn't work that well. I have searched high and low for an answer and now I am desperate, if someone could point me in the right direction to a simple solution. That would be great. Much appreciated for any responses. |
6 | What is a good algorithm for generating a linear regression of positions in 3D space? (for getting the direction of a thrown object in VR) I'm trying to get throwing to feel right in my VR game. I don't plan on actually using physics to do this my idea is to accurately determine the lateral direction of the throw, then move the object in the intended direction (with a doctored Y value) at a speed dependent on other factors. The language of the code doesn't matter too much, but I'm using Godot, so something that wouldn't require me to import a bunch of different math libraries (by converting them to Godot's Python style GDScript) would be ideal. It doesn't need to be robust. To give you an idea of what I was thinking, my original plan was to save the position of the grabbing controller every frame while an object is being held, removing old positions if the controller is moving backwards, then averaging out the movement deltas over the last 10 or 15 frames or so before letting go (it should be consistent since Godot has a fixed timestep "update" function available) and normalizing the vector to get the direction the object should travel in. However, this blog post got me thinking that spending the time learning how to do the linear regression in a more robust way, then applying that to 3D VR, might be worthwhile. I just wonder if, since I don't need the actual linear or angular velocity, it might be overkill in terms of time spent on the feature. |
6 | How do I handle moving platforms in a platform game? I don't want to use box2d or anything, I just want simple moving platforms (up down, left right, diagonal and circular paths). My question is to handle the update order control hierarchy so that the player stays fixed to the platform solidly, without bouncing or wobbling? |
6 | Applying angular velocity distorts model I am calculating the orientation of a sphere through the following code wV new Vector3(0, pi 2, 0) w new Quaternion(wV, 0) o is the current Orientation o.Normalize() w 0.5f w o dt is the elapsed time since the last frame o w dt However it seems that over time the sphere tends to become distorted and then shrink back to its original size. Is this due to the simplicity of the integration or am I doing some simple mistake? |
6 | How to make a character jump? I am currently making a game in C using Direct X 9.0. The game remake is Donkey Kong NES. I have nearly everything completed, but I am having problems with the physics of Mario's jump. I have variables declared for the Y and X co ordinations. I was wondering if there was a simple method of doing this. I have searched high and low for an answer but the answers I have found are either irrelevant or using a different programming language such as XNA. I currently have a bool variable set to check to see if W has been pressed then that will trigger any code to make him jump. I have been messing around such as. if (jump true) Playerypos vel Playerxpos vel Which didn't work that well. I have searched high and low for an answer and now I am desperate, if someone could point me in the right direction to a simple solution. That would be great. Much appreciated for any responses. |
6 | Dashing mechanic in top down projectile dodging game in pygame im making a simple third person top down game where you dodge projectiles than fly in from either side of the screen, its a simple high score game where the longer you avoid being hit, the better your score. i want to give the player the ability to dash in any movable direction by using a resource (lets call it a dashcoin) if the player collides with a certain target, they get one dashcoin, which can be expended to dash forward at increased speed for a brief moment. im also hoping to remove player control while they dash this is the entirety of the code right now. currently theres no projectiles to dodge, but im working on that. import pygame pygame.init() win pygame.display.set mode((630, 530)) pygame.display.set caption( quot Cube Dash quot ) x 250 y 250 width 30 height 30 vel 3 run True while run pygame.time.delay(10) for event in pygame.event.get() if event.type pygame.QUIT run False keys pygame.key.get pressed() if keys pygame.K LEFT and x gt 60 x vel if keys pygame.K RIGHT and x lt 550 x vel if keys pygame.K UP and y gt 10 y vel if keys pygame.K DOWN and y lt 490 y vel if keys pygame.K ESCAPE run False win.fill((0,0,0)) pygame.draw.rect(win, (255, 255, 255), (x, y, width, height)) pygame.display.update() pygame.quit() im completely new to pygame and got most of this from tutorials, so any help is appreciated |
6 | Gravity wells that go with finger I have a simple particle game, where all the particles are arranged in a grid. This game is for touch devices so to take advantage of it I am trying to have a multitouch gravity field thing going on. Basically I am trying to get it so that each finger is basically a well in an otherwise non existent gravity field. That way the particles are pulled towards a finger. My problem is I don't even know where to begin with these calculations, I have tried averaging a particles distance to each finger, its direction to each finger and nothing seems to work nicely! I have seen other games do this. What does the math for it look like? |
6 | Which Box2D like physics engine parameters need pixel conversion? The official guide does not have any useful details on the matter http www.box2d.org manual.html Position is an obvious one. What about velocity? Density? Anything else? Update the context is wrapping interfacing a physics engine to make it more usable. E.g. units of measure in the game editor should be consistent. |
6 | What is original Pong ball behaviour? I am building a Pong clone to learn interactive programming and I've stumbled in getting the ball movement and bouncing on the paddles right. If I play the original game I can't really understand how the "spin" and the paddle bounce works. I've been searching a bit on the internet and all I got was just more confusion. Can anybody explain me how the bounce is handled? If the paddle stands perfectly still and the ball, just moving on x, hits the paddle at the center I simply get x, that is clear. What happens if you hit the paddle on the sides? What changes if when the ball hits the paddle the paddle is also moving? I did an Arkanoid like implementation but it is far from the real Pong feeling. |
6 | 3D Coulomb Friction Use Collision Impulse To Calculate Friction Force? I've been using this document to learn how to implement a very basic physics engine. The section on Coulomb Friction on page 55 56 (marked as pages 43 44) confuses me. It observes that the friction force can be calculated using the collision impulse (jr). This seems strange. Envision an object falling very quickly onto a plane with a slight incline. The object is rotating in the opposite direction it would if it were rolling down the incline. When the object makes contact, it will have a small velocity along the tangent, but a huge normal impulse (jr). This will result a very large change in velocity along the tangent (t hat) opposite to the direction of motion. This will push the object up along the surface (bad!) with a notable amount force. My implementation confirms this. Can someone explain to me how this all fits together? I'm very confused. P.S. I don't think trying to provide an example of my implementation here is relevant, either the effect I'm explaining cannot occur (in which case there is a bug, which I can find myself), or I'm misunderstanding the equations, in which case the implementation is inherently broken |
6 | Destructible Terrain like worms I have to develop a game with a dynamic destruction of the map, I searched the internet and even looked at some questions regarding this topic on this Website, but they did not help me much out. I made the map with tiled and used box2d to make collision between the game objects. As a game engine we have to use Libgdx, but I dont know how to start as I had never develeped a game before, can someone give me any tipps how I could start? with regards, |
6 | Using fixed timestep and interpolating states makes physics fall behind one frame. Does that affect responsiveness? The title says it all, but let me build more into the question I suppose everyone by now knows the Fix Your Timestep article, and its proposal to free your physics engine steps from your rendering steps. Which you can accomplish by accumulating time generated by the renderer and consuming it in fixed step sizes. The interesting part is that Glenn Fiedler tells you to interpolate the previous and the current frame, which lead me to the following question Doing such will make the rendering lag one frame behind the physics. Won't that affect my input responsiveness? Since I'll take one more frame to see the results of my actions. One may be inclined to say that one frame doesn't make that much of a difference, but then, these three articles of Mick West, one of the founders of Activision and former programmer of "Tony Hawk's Pro Skater" series says otherwise Pushing Buttons Measuring Responsiveness in Games Programming Responsiveness So again, the question Interpolating the previous and current frame, will make me lag one frame behind. Will that hurt my input responsiveness? |
6 | Looking for very simple implicit integration example I am trying to design a robust cloth system. I have no problem at all simulating things like that using forward integration such as euler, midpoint, runge kutta, verlet, etc. However, I just can't wrap my head around implicit methods. I don't understand how you formulate the equations in linear algebra terms. I'd really like to see a VERY simple tutorial, and an actual example of how to construct the equations, and then solve for a very simple system (for example, 3 particles connected by 3 springs). I looked into David Baraff's Large Steps in Cloth Simulation, and I can kind of follow it, but going from equations to code is a weak spot of mine. I can use a package like eigen to solve, but I'd also really like to see some code for something like conjugate gradient descent. I don't care about efficiency at the moment, I just want to be able to clearly understand what's going on. Thanks |
6 | Path following with Asteroids like movement. Time to complete path I'm currently learning about how to do this, but it's best to post the problem beforehand. (posting on Physics and GameDev, as you guys know your math) It's quite difficult to explain. This specific problem revolves around a problem of creating a guidance system for rocket powered craft. Think 'I want the ship from game "Asteroids" to follow a specific path and compute, how much time will the whole trip take beforehand" A craft has it's own properties like mass, linear and angular acceleration. It is only able to accelerate in its forwards direction. Also, quite a pain in the... it's maximum traverse velocity is limited. Hopefully the picture clears some things out The problem lays in the very first step. The program is initiated while the craft is already moving with random velocity and faces random direction. In order to move fully toward the target point, first the craft has to turn to face "U" vector. But while doing so, it still moves, so the vector "U" will change. From the picture you can see that the direction of turn can change, don't worry, it's not a problem. So, the problem. I tried using only vector math, but with no success as the variable I'm trying to compute relies on equations involving this variable. I'm too dumb to get only the variable I'm interested in on one side of equation. I think the solution would involve a function of distance from craft to object over time. Edit 1 For your interest. Here is the part where I get stuck. From the beginning. We have the craft on initial position "A", travelling with velocity "V1" and the target on initial position "B", with velocity "V2" (better include it just in case) From that we can compute the burn vector "U", that we need to align ourselves to in order to travel towards the target at the speed of "Vmax" The bigger the angle between craft's heading "Cf" and vector "U", the longer it will take the craft to turn. Which means, the craft will cover more distance while turning (uppermost picture). Which means the angle will change during turning etc. etc. On second picture, in red box. at the top we compute dot product, at the bottom we multiply magnitudes of vectors. As the Cf vector is of length 1 all the time, we can spare it. The primary thing I'm looking for is variable "t", currently I'm out of ideas. |
6 | Physics engine and squishing of stacked objects I have a general question that seems to apply to most physics Engines (Box2D, Unity, Matter.js, ). I'm trying to make a tower of rectangular objects that are stacked on the static mass infinity ground, and the more blocks I have, the more they "squish". I put together a test case in CodePen, which is reproduced here var canvas document.getElementById("canvas") var context canvas.getContext("2d") var width canvas.width var height canvas.height physics vars var phys Matter var bod Matter.Body var bodies Matter.Bodies var engine var render var world var optionsForBodies Florian restitution 1, var boxNumber 0 TEMP const keyState window.onkeydown function (event) keyState event.code true window.onkeyup function (event) delete keyState event.code TEMP Add bodies to matter function loadMatter() var floor phys.Bodies.rectangle(100, 225, 200, 50, isStatic true ) var blist floor for (var i 0 i lt 13 i ) for (var i 0 i lt 2 i ) var box bodies.rectangle(100, 200 i 20, 56.8, 20, optionsForBodies) blist.push(box) boxNumber 1 phys.World.add(world, blist) function drawMatter(name) var bodies phys.Composite.allBodies(world) for(var i 0 i lt bodies.length i ) if(!bodies i .render.visible) continue var verts bodies i .vertices if(verts.length lt 0) continue context.fillStyle " aaa" context.strokeStyle " 000" context.lineWidth 2 var ofsx 0, ofsy 0 context.beginPath() context.moveTo(verts 0 .x ofsx, verts 0 .y ofsy) for(var j 1 j lt verts.length j ) context.lineTo(verts j .x ofsx, verts j .y ofsy) context.lineTo(verts 0 .x ofsx, verts 0 .y ofsy) context.fill() context.stroke() function updateMatter(ms) phys.Engine.update(engine, ms) function clrCanvas() context.fillStyle " fff" context.fillRect(0, 0, width, height) var inter function init() initMatter() clrCanvas() requestAnimationFrame(step) function initMatter() engine Matter.Engine.create() world engine.world world.gravity.y 3.0 render Matter.Render.create( canvas canvas, engine engine, options width 400, height 300 ) loadMatter() var frameNo 0 function step() var SCALER keyState.KeyA ? 3 1 var SPEED 16 SCALER if (frameNo SCALER 0) updateMatter(SPEED) clrCanvas() drawMatter() requestAnimationFrame(step) init() lt script src "https cdnjs.cloudflare.com ajax libs matter js 0.11.0 matter.min.js" gt lt script gt lt body gt lt canvas id "canvas" width "400px" height "400px" gt lt canvas gt lt body gt To me what's happening is not obvious and I'd love an explanation in human words, since in real life if you stacked crates they would not squish inside each other, but it's a constant with EVERY physics engine, despite playing with restitution, slop, damping, density and many parameters. Ideally I'd like those crates to be dense enough to absorb a big part of the shock ( not bounce much) of each other and never penetrate each other. What concepts am I missing? In the codepen above, try to select the canvas and then press the 'A' key, which reduces the framerate (increasing the dt from 16ms to 50ms) which increases the forces computed for the objects at each iteration and therefore penetrating even more each other. Thanks!! |
6 | Calculate Jump Limits My question is in a similar vein to this question, I am creating a pre mapped pathfinding solution much akin to how Ash Blue was for my 2D platformer style game (in XNA). As part of the process, I have to be able to 'neighbor' nodes in the pathfinding algorithm. To be able to do this, I need a procedural manner to precalculate the maximum capabilities of motion from a given game object at a given location. I am having a difficult time with one specific aspect of this I cannot, for the life of me, figure out how to test whether or not a game object will be able to successfully jump to a given platform from where they are standing. I know there's a way to express this in some manner of equation, but I cannot find what the proper equation would be, it's probably in the vein of projectile physics, but the answer eludes me. If anybody can shed some insight into the matter, I would be very grateful. |
6 | How to create simple physics for a group of balloons colliding in the screen (2D) The game is 2D, how can I make simple physics for a group of balloons colliding in the screen. What I need is the balloons not to overlap and to bounce when they reach the limits of the screen or other balloons. Should I use something like box2d or is there a simple algorithm to do something like this? |
6 | Why are my objects becoming permanently stuck to walls using Box2D? I setup a simple simulation environment something like billiards. There are four circle balls (dynamic) and four box walls (static). Simulation works... except one thing. Sometimes when a ball rest against a wall, it sticks to the wall eternally. The other balls hits the stuck ball so many times, but the ball never wants to separated with the wall. The only situation where the ball will become unstuck from the wall is another if another ball is rests against the same wall such that it hits the already stuck ball. Why does this situation occur? How can I avoid it? |
6 | Simulating elastic ball collisions quickly escalates to disaster I'm trying to learn HTML canvas and was working on a basic physical simulation, where a number of balls are drawn and set in motion, and the program simulates them colliding and bouncing off the walls and each other. Here's the simulation. Each ball is initially given a random position, direction, and a constant starting velocity. For simplicity, a ball's mass is simply equal to its radius. The velocity vectors are stored as (x,y) instead of polar coordinates to make the calculations simpler and the simulation faster, but this apparently has unintended consequences. In the simulation linked above, I'm starting with ten balls, and each ball has an initial velocity magnitude of 3, so the total initial "speed" of the system should be 30 ( 10 3). On each frame, I calculate the total speed of all the balls and read it out in a form field, and with uniform balls of size 10, the total speed seems to stay a few units under 30. The same is true of the min and max radius are decreased so all the balls are size 5, or increased to 20 the total speed stays relatively uniform. However, interesting things happen when the balls vary in size. If the minRadius is changed to 5 and maxRadius to 15, for example, you'll notice that the total speed of the system starts climbing over time. The bigger the difference, the faster the speed grows out of control. SO my first guess is that I screwed up the physics, but I can't figure out how. My other guess is that this is caused by accumulating floating point error, but it's interesting that it only grows upwards, and never towards zero. Also, it does seem to have a limit while it constantly fluctuates, it seems to be capped at some value related to the delta between the minimum and maximum ball size. My question is really to understand why this is happening? Did I just screw up something simple, or is something more sinister going on? |
6 | Server side physic simulations with hundreds of players I m currently working on a singleplayer physics orientated game where I would like the physics to be simulated server side. This because the game will have leadersboards, persistant player progression, etcetera and I want to prevent any type of cheating basically a pure client server architecture, the client is dumb and only displays what the server wants you to display. The problem however is that the game will most likely be played by hundreds (maybe thousands) of people at the same time. This concerns me, as it will most likely kill server processing power if I have to do and maintain hundreds of states at the same time. I would have no problems moving all of the physics simulations to the client side, but then I would really need a way to validate if the result of a client simulation is valid. However, I can't figure out how. I have thought about running the simulation server side once in a while to validate if the client is still playing fair, but I really want the server to have as less strain as possible. Physics will become about as complex as the GDC 2011 demo by Glenn Fiedler, maybe even simpler. However, a lot more always colliding rigid bodies will be in a single scene and they will all be visible at once. I have a hard time getting an answer to this particular case, as most resources on the web again, Glenn Fiedlers site being a great one speak about small scale networked physics (eg. a FPS with 30 players, like Halo). Any advice, websites, papers or the like on the subject will be very appreciated. A recap of the questions I would like an answer to How feasible is a client server model? Is my server processing power concern legit and grounded? Is it possible to reliably validate a physic simulation run by the client on the server? If so, how? |
6 | How to adjust my games speed to fps Hi so i am making a small sort of physics engine, but if your fps is really slow the physics will update slower and objects will move slower. How do i make the speed of objects greater if the fps is lower so that on a computer with 5 fps the object will land at the same time as on a 60 fps computer? (just with that slow framerate) |
6 | How to get plausible platformer physics with Farseer on MonoGame XNA? I am creating a 2D Vectorial (made of polygons, not tiles !) platformer using MonoGame and Farseer Physics Engine. Everything works perfectly, except the movement of the character which doesn't feels right for a platformer, because Farseer is a physics engine... I would like to have any advice to achieve a natural feeling like Mario . I didn't choose to make my own system because I'm simply not good enough to do something like this. I've seen some questions already about it, but none had useful answers (they said like 'You have to do a lot of tweaking', but how do I do that exactly ?) I could eventually use another engine that works for collision detection response and that gives me more control over the player entities, but i didn't find any yet. If you know any solution that's simple to use and that corresponds to what I need, then i'd love to hear it ) Thank you for any help. PS Also, I am soon going to try to create AIs for my game. How would I make them move with great control (like the player) ? |
6 | How do you apply relativistic physics to a 4x strategy game? I had the big idea of trying to create a hard science fiction 4X strategy game (with the obvious space setting), which is supposed to simulate a realistic way of creating interstellar societies while simulating real life physics as well. The problem is how do I apply Einstein's relativistic equations into the game? I will make a separate series of questions for other issues, such as applying Keplerian planetary movement and Newtonian combat physics. Do note the game is being made in C and in Unity. Be warned I am trying to simulate special relativity, not general relativity quite yet. That I can try in a different game. |
6 | Godot How do I get the id mask for a physics layer by name? I would like to figure out whether a collider is in a physics layer by the name (string) I set in project settings func physics process(delta) var collision move and collide(direction delta speed) if collision and (collision.collider.collision layer amp get collision layer("Walls")) ! 0 direction direction.bounce(Vector2.LEFT) more behaviors based on other layer tests Walls is the name of the physics layer and I am trying to find get collision layer. I am using Godot 3.2.1. self is a KinematicBody2D amp colliders are StaticBody2D's amp also KinematicBody2D's. I have figured out the collision id (as an int) but still think it would be cleaner to use layer names, preferably using a built in function. |
6 | Cocos2dx Physics Abort() When Changing Dynamic PhysicBody to Static? I just learned cocos2dx v3.3 integrated chipmunk physics engine. Here ,as you see, I create a simple circle with physic as auto sprite Sprite create("circle.png") auto body PhysicsBody createCircle(sprite gt getContentSize().width 2) body gt setContactTestBitmask( 1) active collisions event sprite gt setPhysicsBody(body) sprite gt setPosition(...) this gt addChild(sprite) When I toggle this circle static dynamic in normal situation everything work fine and when circle become static it stop in its position (as we expect gravity don't move it longer). here is a toggle code which works fine body gt setDynamic(false) scheduleOnce( (float dt) body gt setDynamic(true) ,3,"Back to Dynamic Mode Timer") PROBLEM BEGINS But I want when the circle collide with something else ( in my case screen edge with is not important part of scenario), it become static then. so I use below code auto contactListener EventListenerPhysicsContact create() contactListener gt onContactBegin (PhysicsContact amp contact) gt bool return true contactListener gt onContactPostSolve (PhysicsContact amp contact, const PhysicsContactPostSolve amp solve) contact.getShapeA() gt getBody() gt setDynamic(false) gt Cause Abort() ! eventDispatcher gt addEventListenerWithSceneGraphPriority(contactListener, this) But I just face a abort() message and game exit. The call stack ( God bless it) show that the error is comming from line 300 in CCPhysicsBody.cpp if ( world ! nullptr) cpSpaceRemoveBody( world gt info gt getSpace(), info gt getBody()) |
6 | Find meeting point of 2 objects in 2D, knowing (constant) speed and slope I have a gun which fires a projectile that has to hit an enemy. The problem is that the gun has to be automatic, i.e. choose the angle in which it has to shoot, so that the projectile hits the enemy dead in the center. It's been a looooong time since school, and my physics skills are a bit rusty, but they're there. I've been thinking to somehow apply the v d t formula to find the time needed for the projectile or enemy to reach a certain point. But the problem is that I can't find a common point for both the projectile and enemy trajectories. Yes, I can find a certain point for the projectile, and another for the enemy, but I would need lots of tries to find one where the two points coincide, which is stupid. There has to be a way to link them together but I can't figure it out. I prepared some drawings and samples A simple version of my Flash game, dumbed down to the basics, just some shapes http axonnsd.org W P001 MathSandBox.swf click the mouse anywhere to fire a projectile. Or, here is an image which describes my problem So... who has any ideas about how to find x3 y3, thus leading me to find the angle in which the weapon has to tilt in order to fire a projectile to meet the enemy? EDIT I think it would be clearer if I also mention that I know the speed of both Enemy and Projectile and the Enemy travels on a straight vertical line. |
6 | Timestep schemes for physics simulations The operations used for stepping a physics simulation are most commonly Integrate velocity and position Collision detection and resolution Contact resolution (in advanced cases) A while ago I came across this paper from Stanford that proposed an alternative scheme, which is as follows Collision detection and resolution Integrate velocity Contact resolution Integrate position It's intriguing because it allows for robust solutions to the stacking problem. So it got me wondering... What, if any, alternative schemes are available, either simple or complex? What are their benefits, drawbacks, and performance considerations? |
6 | Get project's gravity value in Godot I need to get access project's gravity value which set in Project Settings Physics 3D Gravity, however I couldn't find any related information about this. How do I get project's gravity value in GDScript? In Unity, it can be done by simply Physics.gravity, but in Godot, couldn't find similar. Using Godot 3.1.1 |
6 | How to prevent bullets from passing right through entities? (sorry for bad english) I'm making 2D arcade game. I write all of physics stuff myself. The problem involves bullet behaviour. Imagine bullet flying towards some entity. If the bullet's velocity is relatively high and the entity is small, the bullet passes right through the entity which is obviously not what it's meant to do. Here's the gif that shows why that happens (values are exaggerated to better show the process) As you can see bullet's velocity is simply bigger than the size of the entity. Then I came up with this Getting point of impact coordinates means I can check if the distance between the point of impact is smaller than the bullet's velocity. If the distance is smaller then bullet should collide with the entity at the point of impact. But I don't know how to calculate the coordinates of the point of impact. Pls help. |
6 | Spider physics to patrol on platform smoothly when changing direction I have a 3 tile wide platform. I want my spider to hang from the ceiling and patrol this platform left and right. I have dx property for velocity. I want a physics code that shows how to achieve this. I tried this but it is too harsh if (dx lt 0 amp amp !base.isSolid( 16, 1)) dx 1 else if (!base.isSolid(16, 1)) dx 1 What I want spider is to slow down on edges change direction and speed up. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.