_id
int64 0
49
| text
stringlengths 71
4.19k
|
---|---|
6 | How can I resolve collisions a little better? I'm currently developing a physics engine and I'm not sure the best way to go about resolving my problem. I have a little box, that I can move around with in my scene. When I'm resolving collisions, I take in the two bodies that are colliding, determine what both of their normal forces are and apply it to them (I also multiple it by a small number, if I don't I can't continue to walk around the scene). Anyways, while I'm resolving the collision I do this a.Position a.Velocity b.Position b.Velocity I know this isn't a very good way to resolve the collision, but I'm just not sure how to do it correctly. How should I go about resolve collision correctly? Also, here is the whole method I use to resolve collision at the moment private void ResolveCollision(Body a, Body b) Calculate normals forces (N M G) Vector2 normalForceA this.CalculateNormalForce(a) Vector2 normalForceB this.CalculateNormalForce(b) Resolve collision, which is super buggy and obviously a bad idea. a.Position a.Velocity b.Position b.Velocity Apply normal forces a.ApplyForce( normalForceA 11) b.ApplyForce( normalForceB 11) EDIT This is for a 2D game. EDIT Here is a video of what's going on when I applied TomTsagk's answer. The video is here |
6 | Should I use animated objects or use the physics engine on iOS scenes with lots of rigidbodies? I have a scene with lots of houses and other objects. These objects will be bombarded from the sky. How to handle these kind of settings having in mind that you want the physics to be as realistic as possible. In Unity3D, if I set all the objects with isKinematic true and on collision I set it to false, then the physics isn't as realistic as I want it to be... Can you have these kind of scenes on iPhone? Should I have animated objects? I really don't know what is the best practice in this kind of scenes.... |
6 | Box2D stable range and position Box2D marks stable range of object size is 0.1M 10M. This specifies object size range. How about space size? If I make an 1M object at (1000.0f,1000.0f) position? Is it can be stable? Or should I assume spatial range is also limited same with object size? PS. Maybe the resolution limit is defined because of limit of floating point operations. I believe there's also some limitation on spatial range, but I couldn't figure out specific range myself. |
6 | How to implement the rag doll physics in OpenGL? I'm wondering, having a human model made in blender, how can you make it so that at some point (when the human "dies") the body follows the rag doll physics in OpenGL? I tried looking for some tutorials but I can't found one that fits my requests. Specifically how do you make rag doll physics in OpenGl (and if needed using Blender)? |
6 | How do I program a fan in a platformer game? Fan physics I have a platformer game and want to have fans in it that blow in a given direction and if the player presses the jump button they can go even further. How do I do this? side note I am working with godot engine EDIT My character moves on the two axes using two variables, both multiplied by speed move dir and y velo. gravity affects y velo and the arrow keys affect move dir |
6 | How do I set an object's speed to arrive in X seconds? I want to move an object to a point in the game world, I have the distance value which is far the player should move. I want to complete the movement in X seconds. I have tried many equations and formulas to no success. Speed Distance Time This one doesn't seem to give me the right result. Thing is the game is updated 60 times a second and the movement is affected by delta time. I'm pretty sure I am not taking the framerate in consideration. What am I doing wrong? Edit This is how I calculate the speed int dst 500 int time 2 in seconds float speed dst time Doing it this way is making the movement instant and the game object is not traveling the distance in 2 seconds. Every frame each game objects gets updated this way p.x dir.x speed deltaTime p.y dir.y speed deltaTime The dir vector holds the direction of movement which is calculated on mouse click Vector2 dir new Vector2(mouseX, mouseY).subtract(objectX, objectY).normalize() Delta time calculation long time System.nanoTime() float deltaTime (time lastTime) 1000000000.0f lastTime time Please note The game object stops upon arrival. |
6 | How do I make a character "jump" when leaving an up slope? I have developed a game in Android using a tile based system. I ve implemented 22 , 45 and 67 up and down slopes and everything works (almost) perfect. The problem now is that, when the character gets to the end of an up slope, it justs falls until it finds the ground. I want it to perform some kind of parabola depending on the slope and its speed. I think it s better explained in the picture I already have a function that determines whether or not the character is leaving the slope, I just want some ideas of how to achieve that kind of "jump" in some pseudo code or explanation because I don't know how to start. Any help would be appreciated. |
6 | How to model vehicle driving physics? How to model the physics of a car in a racing game? In real life, vehicle movement is inherited from the wheels. But after reading a few articles on the subject (a lot of which are 10 years old), I realize that the 'real world' physics is in fact often faked with various equations and constants. I want to create custom driving model to learn about it mostly, but I don't want to start wrong so that's why I am here. |
6 | Physic of an arrow in flight What are the formulas which represent the horizontal and vertical displacement of an arrow in flight (as well as it angle)? I would like to make sure that I take into consideration the arrow's fluid dynamics and center of gravity. |
6 | Friction using delta time returns inconsistent result Slowing down a character using the following formula returns different results depending on the frame rate this.y this.yVel delta this.yVel Math.pow(0.99, delta) Is there a better way to decelerate a player using delta time to allow for consistent movement across several framerates? |
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 | Numerical stability in continuous physics simulation Pretty much all of the game development I have been involved with runs afoul of simulating a physical world in discrete time steps. This is of course very simple, but hardly elegant (not to mention mathematically inaccurate). It also has severe disadvantages when large values are involved (either very large speeds, or very large time intervals). I'm trying to make a continuous physics simulation, just for learning, which goes like this time get time() while true do new time get time() update world(new time time) render() time new time end And update world() is a continuous physical simulation. Meaning that for example, for an accelerated object, instead of doing object.x object.x object.vx timestep object.vx object.vx object.ax timestep timestep is fixed I'm doing something like object.x object.x object.vx deltatime object.ax ((deltatime 2) 2) object.vx object.vx object.ax deltatime However, I'm having a hard time with the numerical stability of my solutions, especially for very large time intervals (think of simulating a physical world for hundreds of thousands of virtual years). Depending on the framerate, I get wildly different solutions. How can I improve the numerical stability of my continuous physical simulations? |
6 | How do I get a HingeJoint2D to be rigid instead of elastic? I made a chain of 40 segment using a HingeJoint2D. I followed the instructions directly off this Unity tutorial video But when I start the game the chain bounces and stretches and then slowly over about 20 seconds it slowly pulls it self back up How do I get the chain to actually be rigid instead of elastic? If that's impossible, how do I get them to start in a rest state instead of starting with a bounce? I uploaded the scene here if you want to play with it in Unity yourself. |
6 | How would I go about programming atmosphere for a game? I've recently started making a 2D game, and I want to implement an atmosphere. My plan is to include many in game compartments, such as tubes and ventilation. If I open an airlock from a room with zero pressure to a room with high pressure, I should feel a heavy knock back. If I mix gases in a room, and players both human and alike would not be able to breath, they would die. I have idea of how to do it, but it won't be that sufficient and real. I don't need an real atmosphere it just needs to feel real. This is the small list of what I want to implement Gas pressure that effects the environment, such as moving objects and causing damage to objects. Simple gas mixing, where I would like to implement 4 5 different gasses. Some sort of in game device to affect atmosphere and check its state. How would I go about programming atmosphere for a game? |
6 | Client side prediction in 2D rigid body physics I'm currently working on 2D rigid body physics multiplayer game using Matter.js for physics (both the client and server side) and Phaser3 for rendering. Both the server and the client run the simulation and the server is authoritative. The whole game consists of multiplayer players (who can collide with each other) and objects (boxes, balls, etc). For now, I'm working on the client side prediction and while I understand the main concept, I just can't get it right. Every game tick I gather the client inputs, store them locally, timestamp them and send to the server, while at the same time I start moving the player forward (by applying force). When the server receives the inputs, it processes them (by applying the same forces to the player). The server then sends the current state (coordinates, velocity, rotation, last processed input timestamp, etc) to all players at 20hz. This is the part where it gets tricky. What I currently do, is I force the player to the coordinates sent from the server and apply the same velocity (both X and Y). After that, I remove all locally stored inputs which are older than the last processed input and apply them instantly in a single frame, by doing multiple physics steps. With low latency (20 30ms) it works out quite well, with some jittering when rapidly changing the player direction or when I'm colliding with other players objects, but with higher latencies 70 110ms, the prediction goes completely off. I can see the player constantly being pulled back and forth and the whole game becomes unplayable. I can't wrap my head around, what exactly am I doing wrong? Is client side prediction even the correct way of handling this sort of thing in a rigid body physics based game? Also, I turned off state updating from the server and noticed that the position in the server and locally sometimes goes completely off, for example when I'm jumping, running and quickly changing direction. I believe that means that the physics engine is not deterministic? |
6 | How to account for speed of the vehicle when shooting shells from it? I'm developing a simple 3D ship game using libgdx and bullet. When a user taps the mouse I create a new shell object and send it in the direction of the mouse click. However, if the user has tapped the mouse in the direction where the ship is currently moving, the ship catches up to the shells very quickly and can sometimes even get hit by them simply because the speed of shells and the ship are quite comparable. I think I need to account for ship speed when generating the initial impulse for the shells, and I tried doing that (see "new line added"), but I cannot figure out if what I'm doing is the proper way and if yes, how to calculate the correct coefficient. public void createShell(Vector3 origin, Vector3 direction, Vector3 platformVelocity, float velocity) long shellId System.currentTimeMillis() hack ShellState state getState().createShellState(shellId, origin.x, origin.y, origin.z) ShellEntity entity EntityFactory.getInstance().createShellEntity(shellId, state) add(entity) entity.getBody().applyCentralImpulse(platformVelocity.mul(velocity 0.02f)) new line added, to compensate for the moving platform, no idea how to calculate proper coefficient entity.getBody().applyCentralImpulse(direction.nor().mul(velocity)) private final Vector3 v3 new Vector3() public void shootGun(Vector3 direction) Vector3 shipVelocity world.getShipEntities().get(id).getBody().getLinearVelocity() world.getState().getShipStates().get(id).transform.getTranslation(v3) current location of our ship v3.add(direction.nor().mul(10.0f)) hack this is to avoid shell immediately impacting the ship that it got shot out from world.createShell(v3, direction, shipVelocity, 500) Edit I switched to v3.set(direction) v3.nor().mul(velocity) if (platformVelocity ! null) v3.add(platformVelocity) entity.getBody().setLinearVelocity(v3) And it seems to work (so adding the velocities and setting them on the body). However, I'm not sure what the drawbacks are and why the tutorial application used impulses instead of setting velocities. I also think that while this is physically correct it leads to strange results (gun range is two times further when shooting forward than when shooting sideways). The root cause is because really the shells are indeed too slow, but I like them slow as otherwise the gameplay is too fast paced, and they travel too far. I think I need some compromise between physics realistic and ignore platform velocity. |
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 do you properly implement level boundaries in a physics room? I have an issue with creating a proper boundary in GameMaker Studio when using a physics enabled room. My room has a gravity of 0, as it is in Space. My player object has the default values, but a friction of 10 with a box shaped collision shape. I also use View0 on a 1280x720 room with a 1280x720 view. That is to be able to do screen shakes and other neat effects. I really struggle with containing my player object properly to the room. When I use a collision with view0 boundary and add phy position x phy position previousx phy position y phy position previousy then my ship would get stuck at the screen borders very frequently. I also tried adding some sprites that block the player off the room and created a sprite, 1280x720 and spawned them at the borders. I gave my player empty events for them and set their density to 0, making them static. However, this resulted in the same problem, I got stuck in them. I need a smooth solution for this, obviously, to have a fun experience. I have this problem quite for a while, so please help me understanding how to do this properly. |
6 | How to create skeletal animation data for a skirt? Please think of this in an engine agnostic way first, and then we can talk about specific engines. In my game, I have a 3D character which is wearing a hakama (think of it as a long pleated skirt). This character will be doing a lot of dancing, which I'm getting a lot of motion capture data for. This is how my character is rigged right now (view from Unity) This character has a standard 3D Studio Max humanoid rig, plus a bunch of bones for the "dangling" stuff such as the skirt, the sleeves, the long hair and other parts. Unfortunately, motion capture can only give me data for the humanoid part, not for the additional parts, so I need a way to animate these. For now, let's focus on the hakama (skirt). I have a few ways of doing this Removing the additional bones, and rig the cloth directly to the leg bones This is my last resort, but one that I'd like to avoid, as the hakama will move directly with the legs as if it were a tight fit, losing a lot of realism. Keep the bones and animate them manually. There are just too many frames and too many characters for it to feasible to do this manually, so this is out of the question. Simulate the leg and cloth interaction in some way. Fortunately, the dancing is static (just for cutscenes), so I can do this offline, export the resulting bone transforms for each frame, and apply this to the character during playback. Since Unity has a pretty mature physics engine, I am trying to hack an offline physics simulation that exports the resulting bone transforms for each frame, which I can then playback in real time in the actual game (which by the way is not Unity based). So far, the sleeves and hair have shown some pretty good results, but the hakama is much more difficult, and I haven't gotten it to work even close to decently. I have tried Setting colliders in the legs and the skirt, so when the legs push the skirt, the skirt moves. I can set a bunch of joints to set some constraints, but setting a correct shape and position for the skirt colliders is not trivial, since the leg colliders eventually find a hole between the skirt colliders, which leads to the leg intersecting with the skirt. Instead of colliders, set spring joints between the leg bones and the skirt bones. Unfortunately, springs don't have a concept of "pushing" vs "pulling", and I can visualize a lot of cases where the simulation will lead to the leg intersecting the skirt. Notice that I can't use Unity's cloth simulator, since this acts on polygons directly, and I need to be able to export the results of the simulation in terms of bone matrices. It's not mandatory to use Unity. I just need to find a way to simulate the leg cloth interaction and export the results in a series of bone transforms. Any ideas on how to solve this problem? |
6 | How to obtain "gravity" and "initial impulse" given "desired time to reach max height" and "desired max height"? I'm developing a 2d fighting game, using time steps based on frames ie, each call to Update() of the game represents a frame so, no variable time at all. My jump physics code doesn't need to consider delta time, since each Update() corresponds exactly to the next frame step. Here how it looks double gravity 0.78 double initialImpulse 17.5 Vector2 actualPosition double actualVerticalVelocity InitializeJump() actualVerticalVelocity initialImpulse Update() actualPosition.Y actualVerticalVelocity actualVerticalVelocity gravity It works great and results in a smooth arc. However, it's hard to determine the values for "gravity" and "initialImpulse" that will generate the jump that I want. Do you know if it's possible to calculate the "gravity" and "initialImpulse", if the only known variable is the "desired time to reach max height" (in frames) and "desired max height"? This question should lead to the answer I'm looking for, but its current answer does not fit my needs. UPDATE As MickLH figured me out, I was using an inefficient Euler integration. Here is the correct Update() code Update() actualVerticalVelocity gravity 2 actualPosition.Y actualVerticalVelocity actualVerticalVelocity gravity 2 Only the very first step of the Update() will change and will move the object by initialVelocity plus the half of the gravity, instead of the full gravity. Each step after the first will add the full gravity to the current velocity. |
6 | How to implement "Flick" gesture for throwing an object in the 2D realm I am trying to implement a FLICK gesture for throwing a ball from point A to point B on the iPhone. This is my current plan.... Using touchesBegan and touchesEnd I can find the direction I need to move the ball, and with a small counter, I can impact a certain velocity on the object. My question is simple... Is there a better way to do this ? I am unaware of the physics engine and how I could use it in this scenario. Any good suggestion will help ! |
6 | How would I go about programming atmosphere for a game? I've recently started making a 2D game, and I want to implement an atmosphere. My plan is to include many in game compartments, such as tubes and ventilation. If I open an airlock from a room with zero pressure to a room with high pressure, I should feel a heavy knock back. If I mix gases in a room, and players both human and alike would not be able to breath, they would die. I have idea of how to do it, but it won't be that sufficient and real. I don't need an real atmosphere it just needs to feel real. This is the small list of what I want to implement Gas pressure that effects the environment, such as moving objects and causing damage to objects. Simple gas mixing, where I would like to implement 4 5 different gasses. Some sort of in game device to affect atmosphere and check its state. How would I go about programming atmosphere for a game? |
6 | How can I avoid type checking in the physics side of collision handling? I have a class responsible for handling the physics side of collisions. When the collision detector spots a collision, it notifies both entities in the collision to take care of gameplay. It also notifies the PhysicsGenerator to take car of the physics of the collision. I don't know if it's possible to avoid type checking in the handleCollision() method of PhysicsGenerator. What I wanted to do is apply a force on both entities in the collision to push them backwards. But I can only do this if they are MovingEntities. What if one of them is a StaticEntity? In this case it should be treated differently. I don't know how I can do that without using instanceof quite a lot. How is this usually handled? |
6 | What is closing and separating velocity in Ian Millington's game physics book? I'm working on a physics engine in C and chose Ian Millington's Physics Engine Development book as a guide and reference to help me out understand physics concepts and how to implement them. Yesterday I was reading through the Hard Constraints chapter, particularly the simple collision resolution section and came across an explanation of a physics formula that I couldn't fully comprehend. Millington says quot The closing velocity is the total speed at which two objects are moving together quot and it is calculated with the following formula V c dot P a cdot( widehat P b P a ) dot P b cdot( widehat P a P b ) Where V c is the closing velocity, P a and P b are object a and b respectively. Also he further discusses another formula called the separating velocity which is written as follows V s ( dot P a dot P b) cdot( widehat P a P b ) Where V s is the separating velocity. Now I don't really understand what these formulas actually are or what they represent in the physics world. I also have trouble wrapping my head around why we need these formulas to perform collision resolution since he used the separating velocity formula to resolve the velocity upon collision and why we need the dot product. It would be really helpful if someone can provide visual explanation that would significantly help me understand what's going on. |
6 | Character animation in physics simulated environment What are the standard solutions for animating characters in physics simulated environments? Let me explain what I mean in most games characters are pretty much excluded from physics simulation there are no forces acting on specific body parts (only gravity for the whole character) and limbs are forced to go into positions specified in key frames of animation... which in turn may produce infinite forces on the limbs and we know real muscles have limited strength... What I want is character animation based on simulated muscles with plausible limitations so character walking into a 1 T stone won't move it, or if he gets hit with a fast flying brick he would realistically fall (and brick won't just bounce like from the wall, whit character standing still like nothing happened). Are there libraries that can do that? Maybe free ones for 2D simulations? |
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 | A good place to learn about Game Programming with Mathematical Vectors? I am looking for a place in the web where I can turn my current game development process into a vector based approach. I am sorry If this question has been asked once. According to my google search analysis, few places I've found pretty interesting are Tony Pa's tutorials and Metanet. But, due to limited explanations, I found it little bit tough to implement. I could try out the same examples as provided there, but when I have to use it in my games, I am STUCK. I want to know about the dot products and cross product stuff, Its uses and detecting collisions and predicting collisions with these mathematical techniques. Please, write down some links and a brief description of the link. Thank you |
6 | How to correctly create bullet rigid from custom .mesh in Ogre? Being new to 3d programming and bullet physics in particular, I am wondering how a 3d model or the mesh generated out of it effects the accuracy of bullet physics simulation. I have written a small Ogre 3d application in C , including using bullet for physics. In a small scene I add a plane as ground and three boxes (simple blender objects that come with Ogre) that have their initial position a bit over that ground. So after starting the application those three boxes fall down until they hit the ground plane, where they move a bit, depending on their initial height and rotation, until they come to a halt. Watching that scene the bullet physics simulation looks very accurate and realistic, also the boxes seem to touch the ground very exactly. Ok, then I have created a box model in Sketchup 8 and exported it to an Ogre .mesh file. Then I use this model instead for those three boxes in my scene. The C code itself is not changed at all (except that I load the new .mesh file for the boxes). However, even though on the screen those new box models look exactly as the original ones, their movement is not correct any more. They fall to the ground plane fine, but then they move very weird, it looks not as realistic as before. Even worse, after they have stopped their movement those three boxes now "float" a bit over the ground plane, they do not touch it. I can also see their shadow now below the box on the plane, so they are really not touching the ground plane. TL DR Scene with three boxes, falling down to the ground, simulated by bullet. That works fine with default Ogre (blender) .mesh files for the boxes. But with custom Sketchup models (.mesh files) instead for the boxes, but the same code, the bullet simulation does not work correctly any more. My question is how does the mesh of a model impact the accuracy of bullet? And what can I do to solve that issue with my custom Sketchup models? PS I load the .mesh file and convert it to a bullet rigid body as following m pSceneMgr gt createEntity("Cube1", "Cube.mesh") ... BtOgre StaticMeshToShapeConverter converter(m pSceneMgr gt getEntity("Cube1")) btCollisionShape colShape converter.createBox() |
6 | How can I simulate physics on my curved LED strip? I have a LED strip with 300 LEDs that I can control one by one https github.com cipold pyledstrip You can think of them as Adafruit NeoPixels https www.adafruit.com category 168 I have code to detect the physical positions of all LEDs using a camera and generate an x y heightmap https github.com cipold pyledstrip detector There is some experimental code to make use of the heightmap and let pixels race along the strip like on a rollercoaster https github.com Pixe1 pyledstrip particles Video http mnagel.net oneshot 2018 03 02 particle.mp4 975a194be7cc6fc8 particle.mp4 The "physics engine" within that code is very ad hoc, however. I want to rewrite it into something that more explicitly encodes the physical laws of classical Newtonian mechanics. I can easily simulate particles with mass, position, velocity (acceleration gravity forces). With multiple particles and gravity between them, I would end up with some kind of solar system. Or with constant overall gravity, one particle would fall down in a straight line, accelerating all the time. What I really want is "global gravity" but restrict the particles to move along the path dictated by the LED strip heightmap of waypoints (one degree of freedom along that path). How can I adequately model this restriction with formulas that are still reasonably physically accurate? |
6 | How to apply physics when you have sub frame state changes? I'm currently calculating my physics every 1 100th of a second and using a state machine to manage the current state of the player. In my main loop I'm checking user input and transitioning the state as needed and then my physics code checks the state to apply the appropriate forces. Pseudo if (fsm.state walking) velocity walkVelocity However, the issue I think I've noticed with this is what if a full state transition occurs between two physics frames. For example the user taps jump so quickly they transition from jumping to falling happens so quickly that the physics code hasn't got a chance to see that a jump was requested and therefore doesn't apply the change in velocity. This is a simple example, but I'm feeling that states maybe shouldn't be used this way. Maybe the key presses themselves need to be fed directly into the physics code (so that it can have access to durations and order of events) and then it (the physics code) updates the states accordingly. Is this the common way of arranging flow? Or am I missing something? I.e. should it be Input state change physics Or should it be more like Input physics state change I've seen state machines used with event systems before. So state changes are raised as events which subscribers can respond to. However the physics code still needs to run at fixed timesteps so it needs to be able to query for 'things which have occurred'. |
6 | What are constraints and how are they pluggable? I have been reading this book called "Game Physics Engine Development" and Came across this image in the context of Collision Resolution. See the contact Generator part. Can someone tell me what are constraints and how there can be different types of them? Thank you. |
6 | How does pixeljunk shooter simulate its liquids? I am really impressed by the liquids in pixeljunk shooter. I would love to know how they do it. |
6 | How do physics bones relate to animation bones? Skinned animations use a tree of bones where the child bone (say a finger) is the weighted sum of the rotations of all it's parent bones. Physics bones are defined as a rotation matrix of a primitive (a cube) that has its position constrained by each of its child bones. Is there any correlation with how they map to each other? Can a physics bone be used in place of an animation bone? Thanks in advance. |
6 | Simple collision resolution in a platformer game I want to make a 2d platformer with moving, jumping and wall sliding. How can I make a simple pleasant collision resolution system that works for the following rectangles. Player is red, platform is black, I want to detect if the player is sliding a wall, or hitting the ground, or doing both ( as in third example). Also take the appropriate response. Also I have no idea what I am talking about so a little context might help. These resources helped me How to resolve collision 2D AABBs and resolving multiple collisions How to detect overlap between aabb vs aabb http noonat.github.io intersect |
6 | How to make an object oscillate left and right? I can't seem to make an object move left and right, back and forth, on room start whilst on solid ground. Codes I used Step Event if image index is greater than 5, then physics apply force (0,0,100,0) for the right if image index is less than 5, then physics apply force (0,0, 100,0) for the left |
6 | Friction using delta time returns inconsistent result Slowing down a character using the following formula returns different results depending on the frame rate this.y this.yVel delta this.yVel Math.pow(0.99, delta) Is there a better way to decelerate a player using delta time to allow for consistent movement across several framerates? |
6 | How can I synchronize ocean waves over the network? I've been performing a little bit of research in my spare time on ways to increase the interactivity of environments in a networked game or simulation. One of my areas of research is fluid dynamics and whether it would be possible to synchronize it over the network. I believe the short answer to that is Yes of course you can. But there will obviously be trade offs as there are with any network synchronization problem. I was recently playing Battlefield 4 and a number of their maps have playable ocean areas with fully functional waves large enough to obscure entire boats during gameplay. It seems to work quite well as well. My assumption here is that the ocean simulation is completely offline and each client performs synchronization with the server during initialization. This would allow all clients to run the exact same ocean simulation that appears to be dynamic but is in fact the same offline simulation every time. Interaction with the ocean simulation appears to be only superficial with local splash wave depression. I assume that is entirely local to the client and not synchronized. My question here is Would the above be an appropriate way to synchronize fluid simulation over a networked game? If not, what would you suggest? |
6 | Updating RigidBody rotation and velocity only updates it's rotation I'm currently making spaceship controller script. Control is simple, W S to move forward backward, A D to rotate ship by Y Axis(yaw). Spaceship is RigidBody node and has CollisionShape as children. Here's the code for move forward backward export var speed 1 export var max speed 10 var current speed 0 export var key acceleration KEY W export var key deceleration KEY S func process movement(delta) if Input.is key pressed(key acceleration) current speed speed delta elif Input.is key pressed(key deceleration) current speed speed delta current speed clamp(current speed, max speed, max speed) linear velocity Vector3(0, 0, current speed) I need to limit it's maximum speed, so I updated velocity directly, not using something like add force. Next is rotating code export var yawing speed 0.01 export var max yawing speed 0.02 export var yaw stop threshold 0.001 var current yaw 0 func process yaw(delta) if Input.is key pressed(key yaw left) current yaw yawing speed delta elif Input.is key pressed(key yaw right) current yaw yawing speed delta else if current yaw gt 0 current yaw yawing speed delta if current yaw lt yaw stop threshold current yaw 0 elif current yaw lt 0 current yaw yawing speed delta if current yaw gt yaw stop threshold current yaw 0 current yaw clamp(current yaw, max yawing speed, max yawing speed) rotation.y current yaw In this code, I updated rotation.y directly. Each of this function works if run separately, however run these together, it only changed rotation, not velocity. func physics process(delta) process movement(delta) process yaw(delta) Change order of process movement and process yaw doesn't change anything. If I just run one of process movement and process yaw, it works perfectly. Why my rigidbody ignored velocity and only rotated? Any advice will very appreciate it. |
6 | in Unity3d, how to automatically create fixed joints in a wall of cubes? I want to create a wall width 6 cubes height 7 cubes therefore I have 22 cubes on the margins and 20 cubes inside. For each of the margins cubes(except the corners) I have to set 3 fixed joints, and for the cubes inside the wall I have to set 4 fixed joints all this to have good physics behavior. Pretty much I have to create a fixed joint between a cube and all his neighbors and that's a lot! Is there a way to automatically create these fixed joints? Is there another way to create a physics friendly wall? I want to simulate a wall of bricks hited by a projectile. |
6 | Powder games how do they work? I recently found these two gems http powdertoy.co.uk http dan ball.jp en javagame dust My question is How are the physics with so many elements efficiently handled? Am I just severely underestimating modern computing power or is it possible to 'just' have a two dimensional array, each cell of which describes what is placed at the according position and simulate each cell in every step. Or are there more complex things being done like summarising large areas of the same kind into a single data set and separating said set as needed? Are there any open source games like this I could look at? |
6 | Time complexity of solving constraints in physics engine Erin Catto mentioned in a talk that solving constraints precisely requires cubic time and quadratic space. What algorithm is he talking about when he mentions cubic time? pdf of slides with following quote We can model and program our constraints perfectly. Good enough to drive a robot arm on an assembly line or launch a satellite into space. Unfortunately for games, we do not have enough cycles to solve constraints accurately. Solving constraints precisely requires cubic time and quadratic space. For games we make due with linear time and space, so we are constantly wrestling with our solvers. The better you understand constraint solvers, the better chance you ll have of creating robust simulations in your game. |
6 | Can someone explain Flappy Bird's physics to me? I am having a difficult time trying to understand the Flappy Bird physics. I know it seems simple but I kind of suck at math. I am trying to see if I can make a simple game like this but it is just the dang physics that are throwing me off. I have something like gravity effecting the bird but when you click the screen and I add some amount to the y position but it doesn't look good. You guys have any ideas? Stuff like velocity 9.8 Gdx.graphics.getDeltaTime() position.y 0.5 velocity That is falling but when I tap the device I would like to know how to add upward force but when it loses it continue falling. |
6 | How to program friction in an air hockey game in Cocos2d x 3.11? I'm developing a simple air hockey game, and I have a question about friction of puck and puddles with the game scene. How can I do that? I'm using cocos2d x default physics engine, and the friction setting of physic bodies only applies when they collide. I've found an old air hockey example project, but it seems that it's ported to cocos2d x 3.x so it doesn't use built in physics engine. |
6 | Physics calculating angular acceleration in world vs local space I have a pretty simple rigid body simulation written in Python. In my code I calculate the angular acceleration using formula angAcc torque inertiaTensor 1 (note row major matrix order) Now, the torque is in world space so my inertiaTensor should also be in world space. My Python code that does the angular acceleration computation looks like this oriMat quaternion.ToMatrix(self.ori) inertia world self.inertia local oriMat matrix.Invert(inertia world) angAcc vector.Transform(self.totalTorque, inertia world) oriMat is effectively local to world transform. self.totalTorque is torque in world space. So this code transforms local inertia to world inertia and uses its inverse along with world torque to compute world angular acceleration. This code works completely fine. I thought to check out if I could conduct the angular acceleration compuation in local space and eventually convert local angAcc to world angAcc. Here's the code oriMat quaternion.ToMatrix(self.ori) self.totalTorque vector.Transform(self.totalTorque, matrix.Inverted(oriMat)) angAcc vector.Transform(self.totalTorque, matrix.Inverted(self.inertia local)) angAcc vector.Transform(angAcc, oriMat) Here I wanted to do the torque inertia transform in local space. To do so, I transform self.totalTorque to rigid body's local space using inverse of oriMat. Then I mul that by inverted local inertia to get angular acceleration in local space. Finally, I transform angular acceleration to world space by transforming it with oriMat. For some reason this code doesn't yield correct behaviour of my rigid body and I really can't tell why. Anyone got an idea? |
6 | How does one avoid the "staircase effect" in pixel art motion? I am rendering sprites at exact pixel coordinates to avoid the blurring effect caused by antialiasing (the sprites are pixel art and would look awful if filtered). However, since the movement of the objects involves variable velocity, gravity, and physical interactions, the trajectory is computed with subpixel precision. At large enough screenspace velocities (v t larger than 2 or 3 pixels) this works very well. However, when velocity is small, a noticeable staircase effect can appear, especially along diagonal lines. This is no longer a problem at very slow screenspace velocities (v lt lt 1 pixel per second) so I am only looking for a solution for intermediate velocity values. On the left is the plotted trajectory for a large velocity, obtained by simple rounding of the object coordinates. In the middle you can see what happens when velocity becomes smaller, and the staircase effect I am talking about. On the right, the locus of the trajectory I would like to get. I am interested in algorithm ideas to filter the trajectory in order to minimise the aliasing, while retaining the original behaviour at large and small velocities. I have access to t, instant position and velocity, as well as an arbitrary number of previous values, but since it is a realtime simulation, I do not know about future values (though if necessary, an estimation could be extrapolated under certain assumptions). Note that because of the physics simulation, sudden direction changes can also happen. |
6 | How to correctly create bullet rigid from custom .mesh in Ogre? Being new to 3d programming and bullet physics in particular, I am wondering how a 3d model or the mesh generated out of it effects the accuracy of bullet physics simulation. I have written a small Ogre 3d application in C , including using bullet for physics. In a small scene I add a plane as ground and three boxes (simple blender objects that come with Ogre) that have their initial position a bit over that ground. So after starting the application those three boxes fall down until they hit the ground plane, where they move a bit, depending on their initial height and rotation, until they come to a halt. Watching that scene the bullet physics simulation looks very accurate and realistic, also the boxes seem to touch the ground very exactly. Ok, then I have created a box model in Sketchup 8 and exported it to an Ogre .mesh file. Then I use this model instead for those three boxes in my scene. The C code itself is not changed at all (except that I load the new .mesh file for the boxes). However, even though on the screen those new box models look exactly as the original ones, their movement is not correct any more. They fall to the ground plane fine, but then they move very weird, it looks not as realistic as before. Even worse, after they have stopped their movement those three boxes now "float" a bit over the ground plane, they do not touch it. I can also see their shadow now below the box on the plane, so they are really not touching the ground plane. TL DR Scene with three boxes, falling down to the ground, simulated by bullet. That works fine with default Ogre (blender) .mesh files for the boxes. But with custom Sketchup models (.mesh files) instead for the boxes, but the same code, the bullet simulation does not work correctly any more. My question is how does the mesh of a model impact the accuracy of bullet? And what can I do to solve that issue with my custom Sketchup models? PS I load the .mesh file and convert it to a bullet rigid body as following m pSceneMgr gt createEntity("Cube1", "Cube.mesh") ... BtOgre StaticMeshToShapeConverter converter(m pSceneMgr gt getEntity("Cube1")) btCollisionShape colShape converter.createBox() |
6 | Inconsistent jump height I am doing some physics for a platformer game in MonoGame. The jump height changes based on FPS even though I'm using delta time. When the FPS decreases and gravity is added before movement, the jump height is shorter than usual. How do I keep a consistent jump height at all frame rates? Here's the pseudo code executed each frame velocity.Y gravity dt Move(velocity dt) |
6 | Random map generation strategies for scattering clustering random nodes I am doing a simple 4X strategy game in space where each node is a point of interest (a planet, an asteroid and etc.). To randomly generate a map, I would follow the steps below Decide how many type of each nodes the map will have (perhaps, say, 5 Earth like planets, 10 barren planets etc.) Place each type of node on the map. For step 2 I would like to have an even spread of each node type. So for example, I would start by placing all the earth like planets. If I simply do a rand(map.width, map.height) to determine the position, I may end up all the earth like planets clustering together, which will give advantage to the player who starts in that area. Are there any methods, such as using different graph functions or noise function, which could generate a sequence of (x,y) coordinates which are spread out from each other. Likewise, are there any ways to generates coordinates which are close to each other? |
6 | Unity 2D Hingejoints break under extreme force I have added a rope to my game that is made up of multiple small gameobjects, each connected to eachother by a HingeJoint2D. Since 1 unit of mass in Unity is supposed to represent 1 kg, I've made the player's mass 60 (60kg). When the mass of each rope segment (of which there are 40) is 20, the rope supports the player when they jump off a cliff. Now 20 kg per rope segment sounds ludicrous. However when I make each rope segment weigh 1 (1kg) the hingejoints break completely and jitter around crazily. The force of the 60kg player against the 1kg segments seems to be too much. I would much rather have the rope be lighter, so it doesn't move the player when throwing and being dragged as much. Any suggestions on how to fix HingeJoint2D's and make them act, as you know, a joint should? EDIT Increasing the Position and Velocity Iterations in File gt Project gt Physics2D menu from the default 3 and 9 respectively, up to a whopping 40 fixes this problem. This is a massive increase. Unsure if performance will suffer too much with these new settings. |
6 | How do I determine the slope of a curve? I am making a 2D game where the character rides on the curve of a graph. I need to find out whether the player is going uphill or downhill and calculate speed accordingly. The problem is that I am not sure how to determine the slope of the curve on the point that the character is at. Here is an example of what some of the curves look like |
6 | Calculating displacement in physics simulation Something's been bugging me and I haven't been able to figure this out. In a simply physics simulation, where you'd calculate a net force acting on a body every frame, calculate the acceleration that frame and from that the velocity and then distance travelled. (like this) a F(given) m v a dt s v dt Why is it not s 0.5 vfinal dt (for constant acceleration), in other words, why is not customary to assume that the speed changes linearly during the timeframe dt instead of assuming that the velocity is constant during the frame. |
6 | Is there a javascript physics engine that does not require canvas? I just need a really simple and small physics engine for squares or circles that moves images using javascript. For the project that I am working on, I can't use canvas, so I will be moving the images via the dom. If I understand it correctly, Box2D and PhysicsJS both require the canvas (or at least in my testing that seemed to be the case). I don't really want to make my own, because I bet there is something out there that already does this. So, is there a javascript physics engine that does not require canvas? |
6 | Applying multiple forces on a particle If I have a particle, say in a polar coordinate grid, and I want to apply multiple vectors to it, how can I calculate where it's final position will be given those vectors? Ex. Imagine there's a force represented as a vector, that moves the particle a radius magnitude of 8 at an angle of 45 . Another vector that acts on it at the same time, at magnitude 3 at 90 . How would I calculate the final position of the particle? |
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 do I properly use multithreading with Nvidia PhysX? I'm having a multithreading problem with Nvidia PhysX. the SDK requires that you call Simulate() (starts computing new physics positions within a new thread) and FetchResults() (waits 'till the physics computations are done). Inbetween Simulate() and FetchResults() you may not "compute new physics". It is proposed (in a sample) that we create a game loop as such Logic (you may calculate physics here and other stuff) Render Simulate() at start of Render call and FetchResults at end of Render() call However, this has given me various little errors that stack up since you actually render the scene that was computed in the previous iteration in the game loop. Does anyone have a solution to this? |
6 | Browser sandbox for object interaction testing I m looking for a sandbox where I can upload import STL or OBJ files (rigid bodies that I can export from a CAD software) for quick interaction testing with gravity and contact. The idea is lowest friction possible for import upload so that the time between file export from CAD software to testing of joints and such will be as quick as possible. So things like creating a sandbox template in Unity and then building the game every time would be out of the question. Any ideas? |
6 | Why are we not using integers in game physics? We can use integer for game physics (or without physics, simply object representation) mass, position and rotation, where the integers represent, for example, the number of milligrams, millimeters or (1 56000) of a degree. However, almost all game code I've seen recently use floating points. Is it slower to use integers for game physics calculations? Are there any other advantages and disadvantages from the developer's point of view for using integers? Or it is because all our hardwares |
6 | car crash android game I'd like to make a simple 2d car crashing game, where the player would drive his car into moving traffic and try to cause as much damage as possible in each level (some Burnout games had a mode like this). The physics part of the game is the most important, I can worry about graphics later. Would engine like emini or box2d work for this kind of game? Would Android devices have enough power to handle this? For example if there were about 20 cars colliding, along with some buildings, it would be nice if I could get 20 fps. |
6 | How to obtain "gravity" and "initial impulse" given "desired time to reach max height" and "desired max height"? I'm developing a 2d fighting game, using time steps based on frames ie, each call to Update() of the game represents a frame so, no variable time at all. My jump physics code doesn't need to consider delta time, since each Update() corresponds exactly to the next frame step. Here how it looks double gravity 0.78 double initialImpulse 17.5 Vector2 actualPosition double actualVerticalVelocity InitializeJump() actualVerticalVelocity initialImpulse Update() actualPosition.Y actualVerticalVelocity actualVerticalVelocity gravity It works great and results in a smooth arc. However, it's hard to determine the values for "gravity" and "initialImpulse" that will generate the jump that I want. Do you know if it's possible to calculate the "gravity" and "initialImpulse", if the only known variable is the "desired time to reach max height" (in frames) and "desired max height"? This question should lead to the answer I'm looking for, but its current answer does not fit my needs. UPDATE As MickLH figured me out, I was using an inefficient Euler integration. Here is the correct Update() code Update() actualVerticalVelocity gravity 2 actualPosition.Y actualVerticalVelocity actualVerticalVelocity gravity 2 Only the very first step of the Update() will change and will move the object by initialVelocity plus the half of the gravity, instead of the full gravity. Each step after the first will add the full gravity to the current velocity. |
6 | Player moving up, is he jumping or climbing? In a 2D physics based platformer game that has ladders in it, how do you determine whether the player moving up is caused by a jump or him climbing a ladder, such that you know what animation to play? And in general, obviously the direction vector is not enought to determine the animation to play how do you also determine the cause of the movement (so you know the correct sprite to use)? |
6 | Simple 2D hair simulation manipulation I would like to simulate very simple hair in a 2D environment, and will need to be able to "brush" the hair. What I want to do A 2D character is facing squarely towards the player. The player can then brush the character's hair. Think of a little girl brushing her doll's hair into different styles. In my preliminary Google searches, I found many 3D, super optimized hair simulations for tens of thousands of hairs, which are far more complicated than I need. I only need 100 500 hairs, and they only need to react to "brushing" by the player. How might I do this? |
6 | How can I model the physics of an air blower? I want to model simple lottery machine, it has got a bottom blower. Do you know how can I get force applied to object above blower by air from blower, or equations to model this behavior? Red arrow is blower "wind" |
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 | 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 | Can this script be edited to create a "shotgun" type spread when firing? Top down shooter I have this code and I'd like to add a shotgun to the game by slightly modifying the code. I've looked online for any example but everything I find is for FPS not a TDS. void Shoot () timer 0f gunAudio.Play () gunLight.enabled true gunParticles.Stop () gunParticles.Play () gunLine.enabled true gunLine.SetPosition (0, transform.position) shootRay.origin transform.position shootRay.direction transform.forward if (Physics.Raycast (shootRay, out shootHit, range, shootableMask)) EnemyHealth enemyHealth shootHit.collider.GetComponent lt EnemyHealth gt () if(enemyHealth ! null) enemyHealth.TakeDamage (damagePerShot, shootHit.point) gunLine.SetPosition (1, shootHit.point) else gunLine.SetPosition (1, shootRay.origin shootRay.direction range) I have a basic understanding of most of this code. I don't quite understand how shootRay.direction understands transform.forward means always the front of player. As DMGregory stated adding a variable of some sort that runs through a for loop firing multiple different angles (or simply different coordinates if making angle rays is over my head) is the route I first thought of but I cannot find a way to implement it. I'm having issues with understanding how to manipulate ray coordinates because they cannot be changed by floats which is the extent of my current knowledge of problem solving. |
6 | How would joints work in an impulse based physics engine? I want to learn about physics engines, especially impulse based ones. So I've followed along this tutorial to create some simple rigid body physics http gamedevelopment.tutsplus.com tutorials how to create a custom 2d physics engine the basics and impulse resolution gamedev 6331 I've got this working and it seems pretty solid to me. So I wanted to add revolute (fixed) joints. I've started off with a simple structure struct Joint RigidBody A One body Vec2 AnchorPointA A's anchor point's offset (0,0 if center) RigidBody B The other body Vec2 AnchorPointB B's anchor point's offset (0,0 if center) I'm guessing this would do the job. Now... I'm not too good with physics (hence I started to code this) so I started out what I thought would work RigidBody A joint gt A RigidBody B joint gt B Rotate the anchor points based on the body's rotation Vec2 ancha A gt BodyShape gt Transform joint gt AnchorPointA Vec2 anchb B gt BodyShape gt Transform joint gt AnchorPointB The relative positions of the 2 points Vec2 relativeVel (B gt Position B gt Velocity anchb) (A gt Position A gt Velocity ancha) Apply a force towards eachother, pulling at the anchor points B gt ApplyImpulse( relativeVel, anchb) A gt ApplyImpulse(relativeVel, ancha) This approach simply pulls the bodies together. And it works... Kind of. After the bodies slide together as the joints are set up, it looks ok, but when the bodies fall they tend to spin away from eachother or start to freak out (keep rotating). After messing around with the code (which was getting worse and worse as I was changing it) I've tried to look up solutions on the internet or at least some hints. I've found this How can I implement revolute (hinge) joints in a 2d physics system? But this approach does not apply impulses, it fixes position. Wouldn't be an impulse based system better? How can I fix it? I don't even know how big forces should I apply (I guess it should be based of the distance or something like that and also for the masses of the bodies). Thanks for any help! |
6 | How to handle physics of moving platforms in a platformer? So after a few hours of searching on the internet, I have yet to find a pleasing answer on how to handle moving platforms in a 2d platform game. So I decided to make a simple prototype where you interact with 2 different platforms, one that moves vertically and one horizontally. I would love some help to dissect and see what isn't working, and how to fix them. I have submitted the .fla file .as file below, accompanied with a link to the playable .swf. The goal is to make the Hero interact with the platforms as if they were solid objects that he can stand on, pushed alongside with, jump on under etc etc. The problems with my prototype are these When you stand on the horizontally moving platform, without moving (not touching any keys), the Hero moves along with platform, but with a slight delay causing hero to slide back a little. When you stand on the horizontally moving platform, and jump, you move along with the platform midair (some games prefer having it like this, but it doesn't feel natural and is not wanted here). Which might be caused by the Hero retaining the velocity on the X axis from the platform. When you jump up to the bottom side on the vertically moving platform, whilst the platform is moving downwards, you sink inside it for a brief second. Hero penetrates through as if the collision was non existent for a moment. When you jump on vertically moving platform, the veloctiy on Y axis is retained, so when you walk off the platform, you fall down at a higher speed. With the speed of the retained velocity, gravity that is added (this is mostly because I cant figure out a way to reset velocity on Y axis to 0 when you land on the platform, without the player freezing midair). I'm a novice programmer so I am sure there are BETTER ways to do this, and I would love to hear them all. Any ideas on how to improve the code or other methods in which you can implement moving platforms into a Tilebased game are welcome. In the end, I am trying to find a solid way to handle moving platforms in 2d platformers. Playable SWF http dl.dropbox.com u 28271061 PlatformerhowtoFLA.html (Move with arrow keys, Jump with X key, Run with Z key) Sourcecode AS file http dl.dropbox.com u 28271061 Platformerhowto.as SourcefileFLA http dl.dropbox.com u 28271061 PlatformerhowtoFLA.fla If you prefer just to read the code through Pastie online http pastie.org 2266764 |
6 | Client side prediction physics I'm trying to build a simple networked game and I'm having trouble keeping a jump in sync on the client and server. I've read the free gaffer on games articles and it's helped somewhat but I'm still not completing grasping the theory behind how to keep physics in sync. Right now I have a character that can move right and left. This is kept in sync perfectly by sending all of the inputs and then relaying them to the clients. For the jump command.. I send a packet indicating that i'm jumping. The client then predicts the jump The server begins to simulate the jump and tells the other clients that client X is jumping that then gets simulated on their clients The issue is that if I keep on jumping on the spot eventually the jumps will begin to overlap. I came up with some makeshift solutions to that, but realized that if I started moving and jumping at the same time it wasn't simulating everything perfectly and sometimes the player would land on the tip of a platform on one client and miss it on the server other client. Right now everything is being done locally so there's virtually no lag. I figured the reason it's becoming out of sync is because of jitter. I'm just a little confused in figuring out how to fix this. How do I get it so the client side prediction is 100 perfect in a local environment when incorporating physics? |
6 | Skeleton bone in incorrect spot in game yet, blender rig, skeleton mesh and physics asset are all correct and behave properly I've made a custom character and rigged it in blender. Then exported imported into ue4. It behaves properly in the PHAT and the skeleton mesh looks fine and it all behaves properly in the simulations. In the BP and in game the physics all behave fine except 1 single bone rises above the rest and appears to quot flip quot the root bone for unknown reasons. Almost like all the sudden the root does a 180 and then one specific bone attached rises as a result, not sure if it rises and that flips the root or the root is flipping for some unknown reason. What I don't understand is why everything is fine until it is in game bp. Maybe I'm misunderstanding how physics work with skeleton mesh? I've been banging my head on the wall trying to figure out phat, skeletons and how physics work in ue4 for about a month now and there is basically 0 docs tutorials on this. As much as I love being stuck on this problem forever if anyone has an idea on what is going wrong that'd be great. |
6 | Constant orbit using Rigidbody in Unity I'm trying to make a few game objects (moons) orbit a planet in unity. Basically just picture a planet in the center of the screen, and a few small moons that orbit the planet with a constant velocity. I have gotten this to work nicely using transform.RotateAround(), but I wanted to take advantage of the physics engine that unity provides for realistic "bouncing" of the game objects relative to others as they collide. I have tried a few things such as Hinge Joints, Configurable Joints, and even just adding forces to try to get it to move in a spherical manner. I can't seem to get it to work correctly though. The configurable joint is the closest that I've come, but it's a bit off and it doesn't stay orbiting. It's likely my lack of knowledge with using rigidbodies in 3d, but I figured someone out there could help get me on the right track. Thanks in advance for any help! |
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 | Circle Collision Resolution and Angular Momentum I have a 2D engine working pretty well that involves rectangles and circles. I just reworked parts of the collision detection response system for better handling of angular speed momentum. The collision response algorithm I'm using is described here http www.myphysicslab.com collision.html (the complicated "j ..." equations towards the bottom of the page under "Physics of Collision for Rigid Bodies in 2 Dimensions"). Everything's working great, but I'm wondering about circles. No matter how another another rectangle or circle hits a circle, it's impossible for the circle to gain angular speed through a collision, since the collision normal vector is always perpendicular to surface of the circle. This makes sense to me mathematically, but it goes against my real life intuition. For example, in the picture below, if I poke a ball on the side with a rectangle (tangentially, not towards the middle of the ball), I expect the ball to start spinning (counter clockwise in this case). Why isn't this happening for me? Do I need some kind of non instantaneous collision (deformation maybe?) to experience this effect? If so, is there a way to "fake" it? (Realistically! I don't want to mess up the realistic linear angular momentums and energies of my system!) Thanks in advance for the help!! |
6 | Calculating collision of polygons Say I have a multitude of 2D polygons floating about on a plane. These polygons can have any side count and aren't necessarily regular. Assuming I know absolutely everything about the polygons (area, collision point, location, velocity, rotation, angular velocity... etc) how to I calculate what happens to two polygons after collision? I.e. what will their resultant velocities and angular velocities be after collision? If not an exact solution, what resources could help me learn how to accomplish this? |
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 | 2D Motocross physics I'm looking into making a 2D motocross bike game with plausible physics. It should look like this For a first try, I've created only the player (a motocross driver) and the map (consisting of only straight lines no curves, to keep it simple). How should collisions between the motocross bike and the track affect the bike's position and velocity? The bike should rotate if only one of the wheels touches the ground and speed up if the back wheel touches the ground. Pretty standard bike game stuff. How do I achieve this behaviour? |
6 | Making AI jump on a spot effectively How to calculate, in 3D environment, the closest point, from which an AI character can jump onto a platform? Setup I have an initial velocity V(Vx,Vy,VZ) and a spot where the character stands still at S(Sx,Sy,Sz). What I'm trying to achieve is a successful jump on a spot E(Ex,Ey,Ez) where you have clicked on(only lower or higher spot, because I've in place a simple steering behavior for even terrains). There are no obstacles around. I've implemented a formula that can make him jump in a precise way on a spot but you need to declare an angle the problem arise when the selected spot is straight above your head. It' pretty lame that the char hang there and can reach a thing that is 1cm above is head. I'll share the code I'm using Vector3 dir target transform.position get target direction float h dir.y get height difference dir.y 0 retain only the horizontal direction float dist dir.magnitude get horizontal distance float a angle Mathf.Deg2Rad convert angle to radians dir.y dist Mathf.Tan(a) set dir to the elevation angle dist h Mathf.Tan(a) correct for small height differences calculate the velocity magnitude float vel Mathf.Sqrt(dist Physics.gravity.magnitude Mathf.Sin(2 a)) return vel dir.normalized Ended up using the lowest angle (20 degree) and checking for collision on the trajectory. If found any increase the angle. Here some code (to improve the code maybe must stop the check at the highest point of the curve) Vector3 BallisticVel(Vector3 target, float angle) Vector3 dir target transform.position get target direction float h dir.y get height difference dir.y 0 retain only the horizontal direction float dist dir.magnitude get horizontal distance float a angle Mathf.Deg2Rad convert angle to radians dir.y dist Mathf.Tan(a) set dir to the elevation angle dist h Mathf.Tan(a) correct for small height differences calculate the velocity magnitude float vel Mathf.Sqrt(dist Physics.gravity.magnitude Mathf.Sin(2 a)) return vel dir.normalized Vector3 TrajectoryPoint(Vector3 startingPosition, Vector3 startingVelocity, float n ) float t 1 60 seconds per time step Vector3 stepVelocity t startingVelocity m s Vector3 stepGravity t t Physics.gravity m s s return startingPosition n stepVelocity 0.5f (n n n) stepGravity bool CheckTrajectory(Vector3 startingPosition,Vector3 target, float angle jump) Debug.Log("checking") if(angle jump lt 80f) Debug.Log("if") Vector3 startingVelocity BallisticVel(target, angle jump) for (int i 0 i lt 180 i ) Debug.Log(i) Vector3 trajectoryPosition TrajectoryPoint( startingPosition, startingVelocity, i ) if(Physics.Raycast(trajectoryPosition,Vector3.forward,safeDistance)) angle jump 10 break restart loop with the new angle else continue return true JumpVelocity BallisticVel(target, angle jump) return false |
6 | Manipulating time in Unreal messes up Physics simulation? I'm trying to achive a Super Hot like gameplay, where the time only flows when the player moves. But when I stop time, then restart it, physics simulation will be messed up. Like Cloths starts flying around like they are in a tornado. Rigidbodies fly away, like they were shot from a cannon. All of these without any kind of forces being applied to them. They were just standing still, I stopped time, then I restarted Time and Booom, rigidbodies fly around. I use this in the player's Tick method auto settings GetWorld() gt GetWorldSettings() settings gt SetTimeDilation(timeScale) |
6 | 2D Ragdoll should it collide with itself? I'm working on a ragdoll fighting game as a hobby project, but I have one dilemma. I am not sure if my ragdoll should collide with itself or not, i.e. if ragdoll's body parts should collide. 2D world is somewhat different than 3D, because there are several layers of stuff implied (for example in Super Mario you jump through a platform above you while going up). The setup I'm currently most satisfied with is when only the parts which are joined by a joint don't collide, so head doesn't collide with neck, neck with chest, chest with upper arm etc, but the head can collide with chest, arms, legs. I've tried every different way, but I'm not content with either. Which way would recommend me to go? |
6 | Why is the drag force multiplied by the inverse normalised velocity vector? In pure physics texbooks, I'm seeing this formula to calculate fluid drag force It is clearly stated that it should be opposite to the velocity. Now to me that means, in pseudocode fd get drag(v) using the above formula if v lt 0 fd fd That is, if the velocity is negative the drag should be positive, so we invert the returned value. However, in game code, game physics books and tutorials, I see people doing drag v drag.normalise() fd get drag(v) fd drag That is, we multiply the drag force by the (inverted) velocity unit vector. This to me is logic in regard to the sign, but also it scales down the drag force by a factor between 0 and 1. Which one is correct, and why? PS to be noted, normalisation involves square root, multiplications and divisions, so it's more expensive than a conditional check and subtraction. |
6 | Algorithm for simulating collision between circles of different mass First of all, I'm not sure if this is the right site for this question, as it's actually a game I'm developing. However, I thought that this would be a common thing to need to know in games, so I put it here. I'm programming a physics simulation in which I have a list of balls that are moving around. They have different masses and radii. I am trying to find an algorithm to make them bounce off each other when they collide. I've googled the problem and found lots of solutions for when the balls are the same mass (such as billiards), but none for different mass balls. It's not essential to the question but I'm programming this in JavaScript using p5.js |
6 | Why are we not using integers in game physics? We can use integer for game physics (or without physics, simply object representation) mass, position and rotation, where the integers represent, for example, the number of milligrams, millimeters or (1 56000) of a degree. However, almost all game code I've seen recently use floating points. Is it slower to use integers for game physics calculations? Are there any other advantages and disadvantages from the developer's point of view for using integers? Or it is because all our hardwares |
6 | Physics simulation methods for large delta times? What physics simulation methods are most suitable for really big delta time (hours to weeks)? In addition, would I face any problems combining different methods for big and small delta times? |
6 | How to obtain "gravity" and "initial impulse" given "desired time to reach max height" and "desired max height"? I'm developing a 2d fighting game, using time steps based on frames ie, each call to Update() of the game represents a frame so, no variable time at all. My jump physics code doesn't need to consider delta time, since each Update() corresponds exactly to the next frame step. Here how it looks double gravity 0.78 double initialImpulse 17.5 Vector2 actualPosition double actualVerticalVelocity InitializeJump() actualVerticalVelocity initialImpulse Update() actualPosition.Y actualVerticalVelocity actualVerticalVelocity gravity It works great and results in a smooth arc. However, it's hard to determine the values for "gravity" and "initialImpulse" that will generate the jump that I want. Do you know if it's possible to calculate the "gravity" and "initialImpulse", if the only known variable is the "desired time to reach max height" (in frames) and "desired max height"? This question should lead to the answer I'm looking for, but its current answer does not fit my needs. UPDATE As MickLH figured me out, I was using an inefficient Euler integration. Here is the correct Update() code Update() actualVerticalVelocity gravity 2 actualPosition.Y actualVerticalVelocity actualVerticalVelocity gravity 2 Only the very first step of the Update() will change and will move the object by initialVelocity plus the half of the gravity, instead of the full gravity. Each step after the first will add the full gravity to the current velocity. |
6 | Mobile Physics and movement actions I've been using spritekit for a while for a few small games. One thing I've noticed is that spritekit is the first game framework I've used that allows me to apply move actions to physics bodies. (without anything screwing up at least.) Are there any cross platform game frameworks I can use that allow move actions on physics bodies? Not impulses. I've used cocos2d in the past and when I tried ccmoveby on physics bodies the simulation would get totally confused. I rather not use cocos2d anyway. I'm asking because I want to make cross platform games and spritekit is iOS only. |
6 | How do I create interactive grass like this? I would really like to create grass that reacts to the player's movements, so when they walk through, it moves away from them, just like this https www.youtube.com watch?v 5Gc Ue9 xgk https www.youtube.com watch?v tFgyc8iykLk The problem is, I'm not sure if this is a case of animation, combined with some form of physics, or controlled by a script. The grass looks like 2 planes that are crossing each other and originally I was going to try a LookAtPlayer script, however that would just make the planes spin around to face the player, instead of swaying in the wind, or swaying away from the player when they walk past them. Any advice on how to create something like this with grass? |
6 | How is structural analysis done in games (e.g. bridge building, Dig or Die, and 3D)? From what I understand a typical interactive truss system would need substantial calculations since every component affects the entire system. I think you could arbitrarily stop at a given number of iterations at cost of accuracy in the simulation, but I don't know if that's the approach these games use (bridge building games are an example of truss systems). On the other hand, games like Dig or Die have a quite complex structural system that also takes torque into account (I believe) and compression and is very fast and works on very extensive systems. I guess the basic calculations could be similar, but if not I'm interested in both approaches. Do you guys know how these are made? Do they have an arbitrary limitation or do they use a different algorithm altogether? Also, I guess whatever you guys come up with can be applied to 3D systems but if not or if it's not obvious please at least give a clue on how you could use it for 3D since I'm interested in this for both 2D and 3D games. I know I'm not supposed to thanks here but I find unfair not to at least thank you for your time in advance, I hope this paragraph don't get removed. EDIT If I were to make a guess I'd say Dig or Die stores vectors for each block and then run an iterative algorithm up to a point that the extra accuracy in the simulation is meaningless for the limits of the system (for example, the system would be too large to not collapse anyway), so it's limited by a semi arbitrary (because it's based on application) number of iterations. But I could be wrong. |
6 | Calculate impulse need on object to throw i Y meters into the air, with varying mass Say I have an object that has a variable mass. Now I want to apply a vertical impulse (straight up into the air) onto the object, so it always flies up to the same height. How do I calculate this? So the variables are m mass Y height (constant) If Impulse force G Gravity The origin is always from a floor, so no mid air impulses or anything. (I'm using the Box2D engine, but I think that a solution would be engine independent?) |
6 | When and how should I apply forces in a Cocos2D Box2D game? I have some small circles just rolling across the bottom of the screen in my Cocos2D Box2D iOS app. The bodies are dynamic... so I make them roll by applying a horizontal force to the center of mass (when the linear velocity is below the max velocity). Currently I apply this force in (void) tick (ccTime) dt. Is this the best place to apply it? Or should I subclass something and implement an update function somewhere? Please keep in mind I'm very new to Cocos2D Box2D. |
6 | Multiplayer client side physics I'm trying to handle all the physics on the client and correct data on the server. e.g. Client 1 wants to move right Server broadcasts that Clients simulating Client 1's movement Client 1 sends it's coordinates to the server (every 100ms) Server validates coordinates based on client's last position and last update (which is stored on the server) Server corrects Client 1's coordinates on every client But when FPS lt 60 players are moving faster than they should, which causes server to teleport them back. My question is basically how to check x,y without teleporting players with high latency (or low fps). Server var now Date.now() var clientX ...x position sent by client... var clientY ...y position sent by client... var timeDiff Math.ceil((now player.lastPositionUpdate) 5) 5 var timeDiff timeDiff gt 1000 ? 1000 timeDiff var pixelPer100 player.speed 10 var maximumPixelDiff (pixelPer100 100) timeDiff player.lastPositionUpdate now if (clientX gt player.position.x) var diff clientX player.position.x newX player.position.x (diff gt maximumPixelDiff ? pixelPer100 diff) ..and more Client update function() player.body.velocity.x player.speed tick if (tick 6) tick 0 sendPositionToServer() I'm using Phaser with Arcade Physics. |
6 | Physics engine deltaTime and force acceleration I am working on a physics engine that uses basic Euler integration to compute forces. So, here is the thing function applyForce (rigidbody, force) rigidbody.forces.add(force) function computeAcceleration (rigidbody) rigidbody.acceleration rigidbody.forces mass rigidbody.velocity rigidbody.velocity rigidbody.acceleration time.deltaTime The forces are reset after each gameloop So now imagine I want to apply a force to jump, I will use applyForce at the moment the player presses the jump button. But What happens is that the amount of movement depends on the gameloop speed, since the force is applied for a single frame. I feel like I missed something about how you should use forces, but I don't see how I should manage it properly. In which cases should we use a force, considering this deltaTime issue? And also, what should I use instead? |
6 | Friction due to gravity in an impulse based physics engine In my physics engine, I'm using impulses to solve collisions. I'm basing all calculations on these equations impulse desired velocity change mass impulse force time friction force lt normal force coefficient If an object moves along flat ground (infinite mass), after integration it'll be moving slowly "into" the ground due to gravity. This means that the impulse needed to react to that (given the restitution equals 0) will be the velocity in the direction of the contact normal, multiplied by mass. The issue here is that gravity is a constant acceleration, which means that the object, no matter the mass, will always "dip" by the same amount given a constant frame rate. So the mass is never a factor in this situation, outside of the impulse calculation, which is just a flat velocity change. Now, I can use impulse to calculate the force that was needed to react to the collision, this force can then be used in the friction equation as such friction impulse time lt normal impulse coefficient time Since time is always greater than 0, I can just multiply both sides by it, and then I can use the impulse equation, as such planar velocity change mass lt velocity change along normal mass coefficient And again, I can just remove mass from the equation, which leaves me with planar velocity change mass lt velocity change along normal mass coefficient This is the desired velocity change along the contact surface due to friction. The issue is, obviously, that none of this depends on mass, which means that no matter how heavy or light an object is, it'll always continue sliding along the surface by the same amount given a constant initial velocity. What am I missing? It really looks like there's a logical mistake here. Should the dynamic friction depend on the mass in the first place? Moving a heavy object requires higher force, so static friction should be modeled properly, since it just flat out removes velocity, though it'd be nice to hear if this has merit or just "looks good". |
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 | Fixed physics time step and input lag Everywhere I read says I should fix the time step of my physics simulation, and interpolate the result to the actual frame rate of my graphics. This helps with simplicity, networking, reproducibility, numerical stability, etc. But as I understand it, fixed time step guarantees between 1 and 2 t of input lag, because you have to calculate one step ahead in order to interpolate. If I use 90 Hz physics, it gives me an input lag of about 17 ms, on average. Since I often see gaming enthusiasts talking about 1 ms input lag, 1 ms delay, and how that makes a difference, I wonder how fast action games does it, and how they reduce the input lag using fixed time step. Or they don't, and 1 ms delay is just marketing mumbo jumbo? |
6 | Creating stable tentacle structures I am using verlet integration to simulate some tentacles. So far it works great and I am satisfied with how it looks in general. Here is how a tentacle is built The very stiff sticks are colored red, in addition I added angular constraints of 180 in order to keep everything together. But still, sometimes this happens When forces are too big at the peak, it flips around and gets stuck in a very ugly state. Of course I could increase the number of iterations for satisfying the constraints, but then the tentacles get too stiff and the performance suffers. What can I do about this? Some ideas add more points at the peak more constraints overall limit possible forces maybe rethink my tentacle design completely? detect flip over and undo it |
6 | Altering Animation Playback Given Terrain Information Say my character has a jog animation. Assuming Y is vertical, his feet leave the ground at Y 0 and hit the ground again at Y 0. This works fine in a world like that of Minecraft, where every surface the player could traverse is flat. Now say the character is jogging through hilly terrain. Without any transformations, the animation would break through the ground at certain points. (As the character's foot is lifted and moved forwards, it would go straight through the hill.) How do I remove this artifact? Do I ask the artists to create separate animations depending on the grade of the terrain? Is there a standard system to resolve animation world collisions that I'm unfamiliar with? Or is there another more logical approach I haven't thought of yet? |
6 | How to handle jumping up a slope in a runner game? In an 2D endless runner, what should happen when the player is running "too fast" up a slope and jumps? For example, in a "normal" case .O. . ..O . . O If he is moving to the right slowly enough, he will jump upwards and land on the flat part of the surface. However, if he is moving too fast, the jump will have no effect as his forward motion will bring him back in contact with the slope before he can get high enough to pass over it. When the speed is sufficiently high, there will effectively be no jump. .O O Are there any known ways to solve this issue? I know it's physically correct , but are there techniques that other games use to overcome this in a reasonable manner? As a last resort I'll have to just remove all slopes that are too slanted. If you constrain the player to never jumping backwards. |
6 | How to make a smooth projectile in roblox? I am trying to make a projectile (Energy ball) for my game. I am using body velocities, but the issue is is that it seems laggy. I shoot it then half a second through flight it seems to stop in mid air for a quarter of a second then continue. This only happens the first minute of playing. Here is my code local Motion Instance.new("BodyVelocity", Ball) Motion.Velocity ((MouseClickLocation Player.Character.HumanoidRootPart.Position).Unit 100) Why is the described behavior happening and how can I make it never happen? |
6 | Platformer gravity where gravity is greater than tile size I am making a simple grid tile based platformer with basic physics. I have 16px tiles, and after playing with gravity it seems that to get a nice quick Mario like jump feel, the player ends up moving faster than 16px per second at the ground. The problem is that they clip through the first layer of tiles before collisions being detected. Then when I move the player to the top of the colliding tile, they move to the bottom most tile. I have tried limiting their maximum velocity to be less than 16px but it does not look right. Are there any standard approaches to solving this? Thanks. |
6 | Adding physics to a Blueprint actor in UE4 I am trying to create a dice in ue4 and be able to read off what value it gives. I've made a mesh in Blender and created a texture, imported them and created a blueprint actor and added the static mesh to it. When I start the game the dice just floats in the air and isn't affected by gravity. I have tried just using the static mesh and I can get that to be affected by gravity. However, I need to add scripts to the object so I can give it a random rotation and read its value, so I created a blueprint actor. I've looked online for a way to give this actor physics, nut nothing. Does anyone know how I can add physics to a blueprint actor? Also if anyone has any info on giving the actor a random rotation and reading the value of the dice that would be great. |
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! |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.