_id
int64
0
49
text
stringlengths
71
4.19k
5
How to build a better game save? I am making a roguelike card game like dream quest, and I want to improve my dungeon level save method. Here's what my levels look like I checked dream quest saves but I don't like their method because it uses a simple text file for all the information. it's also really messy, repetitive and not extendable. I used the format below for the first couple of months "Wall", "Wall", "Room", "Room", "Room", "Merchant", "Room", "Room", "Wall", "Wall", , "Wall", "Wall", ... But at the time I did not have multiple enemies, merchants, items. I simply read the file by using an enum which matched the strings used in the save format (item, enemy, merchant etc.) then passed them into an array to create the board. As I started to create different kinds of enemies, items, and merchants, my current game wouldn't support this. I don't want to create an enum like enemy1, enemy2, enemy3 ... How can I improve the scalability amp legibility of this save game format, so I don't have to keep adding new enum categories for each variety of content?
5
Deterministic Procedural Wave Function Collapse I've been looking into the Wave Function Collapse algorithm and was wondering if there is a way to make it (appear) deterministic regardless of starting position. I can see how this is trivial if the starting position remains the same. We can simply always collapse the tile with the lowest entropy and use a seeded pseudo random number generator or a noise function to decide which is next whenever there isn't a clear winner. Now what would be the best solution if I wanted to procedurally generate a world around the player? Say I generate the world in chunks. If a player moves far enough away distant chunks get unloaded and new chunks are generated. This works perfectly fine until the player starts to backtrack. Since tiles depend on their neighbors, a revisited chunk might very well look completely different if approach from a different direction. I can think of two possible solutions a) Always generate the world from a set starting position. This doesn't seem feasible in big worlds, as it would require more resources the further away from the starting position the player is. b) Only generate chunks once and then save them. I don't really like this approach, because it could potentially require a lot of disk space. It's also not really deterministic, because the order in which the player explores the world would still influence what individual chunks look like. Is there a solution I'm overlooking or is this simply not possible because of how the algorithm works? Keep in mind that I don't care if the algorithm itself is actually deterministic regardless of starting position. The result just has to appear that way, so that already visited chunks can be recreated unchanged.
5
2D Procedural resource generation I'm currently building a Mars colonization game and I'm wondering if anyone can point me to resources on how to procedurally create resources and biomes within a 2d game. Much like in a game like Factorio were different resources and such are spread around the map. Thanks in advance!
5
Help Improving Map Generation I've recently attempt for the first time to implement a map generation system and while it does work, it doesn't work exactly the same I want but I'm not really sure on what changes I can make it to make it generate the type of map I want. This is my map generation code lt summary gt Generates a Room at a Start Position lt summary gt void GenerateMap(Vector2 roomStartPos) Vector2 startPos roomStartPos int roomTileNum random.Next(minRoomTiles, maxRoomTiles) for (int i 0 i lt roomTileNum i ) if (CheckTilePosValid(startPos)) Checks if a position is taken by a tile already Tile newTile CreateTile(startPos) Creates a Tile at a passed in Position startPos GetRandomEdgeDirection(newTile.SpritePosition) Gets a Random position next to the passed in Position else startPos GetRandomEdgeDirection(startPos) i It's likely a really bad way of generating a map. It basically gets a random number of tiles to generate, it will then place a Tile at the start position and select a new position in a random direction (Up, Down, Left, Right). It'll then place a new tile at that new position specified, it will then simply loop through that till it's placed every tile. The "CheckTilePosValid()" function is used to determine if the random position that is gathered has already been taken by a tile. If the position isn't taken then it will create the tile and continue through the loop, while if the position is taken then it will get a new position and basically keeping doing that till it gets a position that hasn't been taken already. This generates maps like this The issue is mainly with the first image since as you can see, the map is very stretched out which isn't what I want. I'd more want a map similar to the second image, tiles much closer together and not so stretched out but is still random enough. I'm just not sure how exactly I can achieve this so I was wondering if anyone would be able to help me? Would I need to completely rework my generation system or can I just make simple changes to fix this? I'd very much appreciate the help )
5
Deterministic Procedural Wave Function Collapse I've been looking into the Wave Function Collapse algorithm and was wondering if there is a way to make it (appear) deterministic regardless of starting position. I can see how this is trivial if the starting position remains the same. We can simply always collapse the tile with the lowest entropy and use a seeded pseudo random number generator or a noise function to decide which is next whenever there isn't a clear winner. Now what would be the best solution if I wanted to procedurally generate a world around the player? Say I generate the world in chunks. If a player moves far enough away distant chunks get unloaded and new chunks are generated. This works perfectly fine until the player starts to backtrack. Since tiles depend on their neighbors, a revisited chunk might very well look completely different if approach from a different direction. I can think of two possible solutions a) Always generate the world from a set starting position. This doesn't seem feasible in big worlds, as it would require more resources the further away from the starting position the player is. b) Only generate chunks once and then save them. I don't really like this approach, because it could potentially require a lot of disk space. It's also not really deterministic, because the order in which the player explores the world would still influence what individual chunks look like. Is there a solution I'm overlooking or is this simply not possible because of how the algorithm works? Keep in mind that I don't care if the algorithm itself is actually deterministic regardless of starting position. The result just has to appear that way, so that already visited chunks can be recreated unchanged.
5
How can I incrementally generate an graph? I just started a new project in which I'd like the game world to consist of procedurally generated locations connected by teleporters. After a bit of research, I've discovered this to be called either "graph theory" or "bloody complicated", depending on who is discussing it. Unfortunately, I've found very little information on generating graphs most of the tools I've seen are directed toward examining existing graphs. Assuming I have the terminology correctly sorted out, my requirements are that the graph be simple no location (vertex) should have a teleporter (edge) which connects back to itself, nor should two vertices have multiple edges connecting them connected it should be possible to travel between any two vertices in the graph (though I don't foresee ever needing to find the path simply knowing the player could find one if they chose to is sufficient) cyclic there should be more than one path between any two vertices undirected all edges can be traveled in either direction infinite if the player so wishes, they should be able to travel indefinitely, with the graph continuing to generate incrementally as they approach its outermost unexplored vertices locally finite a vertex's degree should never change after the player has visited it stably labelled each vertex represents a location which will itself be procedurally generated from a seed the same seed must be assigned to a vertex regardless of what path the player used to travel there or how large the graph is when they do I've had some ideas (which I've not yet tried to implement) regarding using the local maxima of 2D perlin noise as vertices (the input x and y could then be used as its label), but that feels clunky and overcomplicated. Is there a better way to generate a graph like this? I'm developing in Python 2.6 using Panda3D and numpy, and would of course be willing to look at including other libraries if they'll help with this problem! Edit I think I've done a poor job explaining some of my requirements, so it's illustration time! Hopefully, this will clear things up. What I mean by having stable labels is that I want, for example, Player A to be able to do a bunch of exploring and find, among other things, a cyclic path back to their starting location and a mountain that looks like a cat. His game now looks something like the following (vertices are numbered with their seed and edges with the order in which the player traversed them). He started on vertex 8329 (green) and Happycat Mountain is in vertex 6745 (blue). Player A's good friend Player B is a fan of cats, so he wants to show it to her. He gives her the root seed for his world and directions along the shorter route to the mountain of interest. Her game should now look like this The problem I'm currently having the most difficulty with is "How do I generate the same seeds for Player B when her exploration hasn't followed the same path?" That's what led me to the idea of using Perlin noise as long as the same root seed is used, the maxima won't move, so their coordinates could be used as stable vertex seeds.
5
Creating a set of islands by subtracting gradient values from a Perlin noise The answers to this question explains fairly well how to create a big island in the center of the screen by setting up a gradient and then subtracting its value from a Perlin Noise. Anyway they explain how to create only one gradient at the center of the screen to create a big, sort of circular island. But what if I want to create an island which has more than one gradient to create a less regular shape, or if I want to create multiple separated islands by setting multiple gradients in different positions? What value should I subtract from the Perlin Noise function for each point? The sum of the distance from each gradient to that point? The average? Edit Jon's method of multiplying and normalizing worked, got this result with 4 gradient points
5
Performance problem with chunked LOD I managed to create Zoomable planet. When I get closer to it the respective chunks are splitting and every split holds 4 x 16x16 grid (1024 verts). When getting closer the respective chunks split again and so on. AT the end (let's say when Im on ground), there is so much splits, that when looking on horizont its about 120000 vertices, what is way to much and drops fps to around 7 12. Where I really want like 3 4 layers near detailed, far less detailed, farest coarse. I can't get my brain around how to fix this. Any advice appreciated.
5
Zooming in on procedural generated 2D terrain? (LOD) My question is what methods are there to "zoom in" on a procedurally generated map using Perlin Noise (or Simplex). If I have for example this generated and I wanted to "zoom" into that little red square I drew, how could I achieve something to the likes of this (ugly drawn) example While staying true to the terrain above? I have heard of 3D methods but couldn't find any meant for 2D maps. Any advice or help would be appreciated.
5
How do I generate platforms in a specific position in godot? I am making a rogue like game in Godot. Currently, I am stuck with the world generation. I know how to add children, but I am wondering if there is a way to add those children in a specific position. I also need to know how to add nodes to an array, and then choose one from the array to spawn.
5
How can you use Fractals to perturb an image? I've been playing around with Procedurally Generated World. I've so far managed to create the Height Map, and a translate map, but now i'm attempting to create Caves, The main idea is to use another Noise map, with values being either 0 or 1, and multiply it with the Height Map. I've managed to achieve this This is currently described with a float Width, Height , which has value 0 for those points (x,y) such that (x,y) is black, or 1, for those which (x,y) is white. I want to apply some fractal to this to achieve this However, i have no idea how to do this! (I also apologize for any grammatical errors. I haven't slept in like 18 hours and i can't think straight)
5
Biome Transition in a Grid Borderless World I have a universe a list of "Systems", each with their own center, type and radius. A small part of such a universe could look like this Systems Can be very close to a different system, e.g. overlap Can be inside another, much bigger system Can be very far away from any other systems Spawn system specific entities and particles inside the system radius Have some properties like background color So far so good. However, the player can fly around freely, inside and outside of systems, in real time. How do I interpolate and determine things like the background color now, depending on camera position? E.g. if you are halfway between a green and a red system you should see a background halfway between red and green, or if you are inside a lilac system near the center and at the border of a green system you should get a mostly lilac background etc.
5
What GPU culling techniques are appropriate for voxel spheres other than octrees? I'm creating a dynamic smooth voxel based world in the shape of a sphere. Right now my current approach is to spherize a cube, generate voxel terrain on each of the six patches, and then use octrees to cull the data further. Octree's are best served with cubes. Is there a better system for storing accessing data in a sphere? I've heard some talk of Octree's not being the best way to store voxel data, even for cube worlds. How can this be? What would be better? A Hash Table? Surely multidimensional arrays wouldn't be faster? Perhaps it's just more of a design decision than performance? As in, maybe someone didn't like chunks popping in so they would rather load individual rows and columns? If it matters, I'm probably going to keep relevant geometry in GPU memory and stream in the surrounding area over time as the player gets closer to it from main memory. I bring this up because I'm really not sure if GPU memory benefits from any particular structure. All I really know is that the parallel powers of the GPU are, well, unparalleled (I had to). How can I tap into that?
5
Making dialogue different with each playthrough I'm making a little demo game where roughly half of the NPCs in a little town have a profession, as well as a personality. I'm trying to have the game procedurally create dialogue, so when an NPC is talking about what they do, they describe it with some personality. So for example, I may have a farmer who's an over achiever. He may have dialogue like this "I farm from sun up to sun down. And I have the most cows around!" In another incarnation, a brainiac farmer may say, "Hi, my farm has exactly five cows, and is run very efficiently." In the demo, the town will be procedurally generated, with a small number of townsfolk (around ten or twelve). Some will be peasants, others will be farmers. One or two will be merchants shopkeepers. When the player talks to some of these folk, the NPC may greet the player and say something about what they do. Or they may describe themselves, as well as something about their town. On occasion, the NPC will also say something about their family. I have thought of using a templating system, where it would fill in some of the dialogue. But I would like the sentences to vary with each playthough. I have also thought of using parts of speech so as to create sentences. The problem with using parts of speech (at least with using NLTK) is that I need some form of grammar to string them all together, and this is mainly meant for a small demo. Another option is to use a natural language generator (NLG), but that's getting into the realm of advanced AI. And I would like to steer away from that. So should I use a templating system for the dialogue (I have tried using Rant, but I got into some really complicated syntax with that)? Or, should I use a dialogue system that uses parts of speech, and strings them together with some kind of grammar? For what it's worth, I'm restricting the NPCs to a group of personalities. Also, some of what they say is based upon their stats. So if their intelligence is low, yet their charisma is high, maybe they'll be a xenophobe, or an over achiever.
6
How to detect if an object is upright? I have a cartoon car and it has a skid sound with the car skids. But when the car flips over the skid sound plays endlessly and its really annoying. I have a basic script that is meant to detect when the car is upright and only play the skid sound with the car is upright. Here is the code This script is on the car itself public bool IsUpright () Vector3 rotationInEuler transform.rotation.eulerAngles float tiltX Mathf.Abs(rotationInEuler.x) float tiltZ Mathf.Abs(rotationInEuler.z) if(tiltX lt uprightThreshold amp amp tiltZ lt uprightThreshold) return true else return false This script is on a skid sound prefab void Update () if(motor.IsUpright()) if(motor.IsMoving()) transform.GetComponent lt WheelCollider gt ().GetGroundHit(out tireHit) currentFrictionValue Mathf.Abs(tireHit.sidewaysSlip) if(skidAt lt currentFrictionValue amp amp skidWait lt 0) Instantiate(skidSound, tireHit.point, Quaternion.identity) skidWait 1 skidWait Time.deltaTime skidEmission When the IsUpright bool (first script) is printed to the console it keeps flickering between true and false and it isn't detecting when the car is upright. By the way the uprightThreshold from the first script has a value of 40. I have also check in the inspector and the rotation of the car on both the x and z axis are not constant at 0, it is flickering up and down between about 1 and 1, but unfortunately unity doesn't support having negative rotation values, so rather it goes to 359, which is mucking up the system. Could someone show me how to fix this? Thanks in advance.
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
How did EA DICE create destructible environments in Battlefield Bad Company 2 and Battlefield 3? How did the folks at EA DICE create destructible environments in Battlefield Bad Company 2 and Battlefield 3? Did they just assemble the buildings out of predefined sub regions, that break apart when there is an explosion or something similar? I can't think of anything else.
6
How to make a character in a Box2D world jump faster? I have a question about using Box2D to simulate a physics platformer. I manage to make the character move to the right and left, and jumping as well. However, jumping seems extremely slow when compared to most tile based platformers. Is there a way to speed up the jumping and falling of the player? I of course know from my basic physics lessons that 'heavier' objects don't fall faster in the real world, but is there a way to simulate this in Box2D?
6
Simple physics for modelling ship submarine movement for a first iteration of my sim, I need a very basic physics model for ship submarine movement. I'd guess it might be a good approach to use vectors here (ship heading but also considering sea states etc.). Basic acceleration and that stuff should be taken into account I do not need any 3D stuff...the 'client' for that 'ship movement' physics is only the 2D rendering of a navigation map. I've found some papers on the net but they are far too complex for my needs. Anybody does know some 'simplified' vector algorithms etc. for that? Thanks a lot. EDIT To be clear I do not want to simulate ship movement ocean physics in detail, because this is not the focus of my (naval) simulation. It 'just' must be somewhat believable in that sense that if you have different sea states(wind waves currents) that the vessel is somewhat believable influenced (on the navigation map) by those forces. The main issue for me is how I model calculate those forces (wind etc.) by simple vectors and (eg. for a given wind velocity like 50kn) in an easy way withouth studying physics ).
6
Lunar lander why is my descent module crashing I've been reading this awesome simulation of the actual Apollo 17 descent http www.braeunig.us apollo LM descent.htm I've been trying to make my own simulation using Euler integration, with a time step of 100ms. The problem is my descent module is crashing during the first two minutes with a vertical speed of 220 m s. During the initial stage of the descent (braking), the lander is tilted 90 and almost all the thrust is spent in the horizontal component, with no force to counter gravity. In my simulation the vertical speed quickly builds up while the pitch is 80 90 , and then gravity does it job. Here's a trace t 0 s x 0 y 17234.6112 vx 1697.1264 m s vy 20.4216 m s ax 1.2995855485404475 m s2 ay 1.6121564579144938 m s2 pitch 90 throttle 0.1297 fuel 8874.2Kg t 10.015 s x 17062.974621379497 y 16948.14950433809 vx 1710.2669538608811 m s vy 36.64853435841286 m s ax 1.3247309786564347 m s2 ay 1.628484797082333 m s2 pitch 90 throttle 0.1297 fuel 8855.501190599978Kg t 20.019 s x 34239.89169813059 y 16498.912567960208 vx 1723.6514116543285 m s vy 53.026163503416676 m s ax 1.3509707026458686 m s2 ay 1.6456786784409965 m s2 pitch 90 throttle 0.1297 fuel 8836.82291908347Kg t 30.026 s x 51527.03405575163 y 15884.74450896862 vx 1725.5675762461628 m s vy 69.5834660661016 m s ax 0.9584923539027193 m s2 ay 1.663174744204344 m s2 pitch 90 throttle 1 fuel 8756.011226046036Kg t 40.041 s x 68759.3217349438 y 15103.315677459259 vx 1715.7571868391299 m s vy 86.32821281208818 m s ax 1.0003892381595199 m s2 ay 1.6806337716945954 m s2 pitch 90 throttle 1 fuel 8611.841531365935Kg t 50.502 s x 86651.75776002374 y 14107.047450672597 vx 1705.0564069549016 m s vy 104.00697912916615 m s ax 1.0452064683102156 m s2 ay 1.6991809596193168 m s2 pitch 90 throttle 1 fuel 8461.251498809865Kg t 134.865 s x 226365.92349700694 y 5.915270639694082 vx 1602.384872970266 m s vy 225.9485740506923 m s ax 1.382111636427434 m s2 ay 1.224439728661491 m s2 pitch 78 throttle 1 fuel 7246.814359289593Kg FINISHED at t 2.24775 minutes However, in the original simulation, vertical speed never exceeds 20 m s. I don't know how could this be possible, as there's no drag due to atmosphere. And I've coded initial acceleration and velocity values exactly as in this very same page. You can check the original trace here http www.braeunig.us apollo LM descent.pdf Here we can see the Moon's gravity is aprox. 1.5 m s which heavily influences ay in my simulation. However in the real descent trace it was kept to lower values ( 0.1) most of the time, even during the first minute when there was no vertical thrust due to the engine. I must be making very stupid mistakes but right now I can't see where. BTW this is how I update my vars in each step Calculate acceleration as a function of mass, velocity, thrust and gravity ax vx vx (y MOON MEAN RADIUS M) (thrust x mass) ay (vx vy (y MOON MEAN RADIUS M)) g (thrust y mass) This would be the acceleration for a flat moon. Don't work either. ax thrust x mass ay g (thrust y mass) Update velocity as a function of acceleration and time. vx vx ax dtSecs vy vy ay dtSecs Update position x x vx dtSecs y y vy dtSecs Any hint would be appreciated. Thanks in advance.
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
How often should I calculate the position of a bullet? In game's like Battlefield or Arma, how many times per second is the position of a bullet calculated?
6
How can I easily implement swinging in a platformer game? I'm developing a game in which player can use ropes to swing (just like what Spiderman or Bionic Commando did) and I'm having problem implementing this behavior. Can anyone help me how to do this, I mean physics formulas and etc. Till now I've come up with 3 ideas. One is using spring, but it consumes a lot of time and sometimes it is jumpy. The other two are trying to calculate next step (one via calculating potential energy and one via calculating torque) and both of them almost crash whenever the actor is trying to swing. Here is the code I wrote to calculate torque float dx Runner gt getPosition().x ancher.x float dy Runner gt getPosition().y ancher.y float t0 atan2(dy,dx) my current angle float k ((dy) vx (dx) vy) (dx dx dy dy) previus angular velocity k gravity cos(t0) dt new angular velocity (gravity is positive) t0 k dt acc cos(t0) dt dt 2 rotate the rope float dx1 r0 cos(t0) new position (r0 is rope length) float dy1 r0 sin(t0) vx (dx1 dx) dt calculate velocity vy (dy1 dy) dt
6
Should the bullet trajectory calculated by server or by client? In a FPS game like Battlefield or Arma, when playing online, should the bullet trajectory be calculated by the server or by the client?
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
Godot How do I get the id mask for a physics layer by name? I would like to figure out whether a collider is in a physics layer by the name (string) I set in project settings func physics process(delta) var collision move and collide(direction delta speed) if collision and (collision.collider.collision layer amp get collision layer("Walls")) ! 0 direction direction.bounce(Vector2.LEFT) more behaviors based on other layer tests Walls is the name of the physics layer and I am trying to find get collision layer. I am using Godot 3.2.1. self is a KinematicBody2D amp colliders are StaticBody2D's amp also KinematicBody2D's. I have figured out the collision id (as an int) but still think it would be cleaner to use layer names, preferably using a built in function.
6
What does maximum normalized frictional force mean in this tutorial? I tried following this tutorial https nccastaff.bournemouth.ac.uk jmacey MastersProjects MSc12 Srisuchat Thesis.pdf, but in page 19 I ran onto a problem I don't understand the step 4. It is also not explained before. Could somebody explain what is it and what values may be used?
6
Simple physics for modelling ship submarine movement for a first iteration of my sim, I need a very basic physics model for ship submarine movement. I'd guess it might be a good approach to use vectors here (ship heading but also considering sea states etc.). Basic acceleration and that stuff should be taken into account I do not need any 3D stuff...the 'client' for that 'ship movement' physics is only the 2D rendering of a navigation map. I've found some papers on the net but they are far too complex for my needs. Anybody does know some 'simplified' vector algorithms etc. for that? Thanks a lot. EDIT To be clear I do not want to simulate ship movement ocean physics in detail, because this is not the focus of my (naval) simulation. It 'just' must be somewhat believable in that sense that if you have different sea states(wind waves currents) that the vessel is somewhat believable influenced (on the navigation map) by those forces. The main issue for me is how I model calculate those forces (wind etc.) by simple vectors and (eg. for a given wind velocity like 50kn) in an easy way withouth studying physics ).
6
Physics engine recommendation which can simulate pool game correctly? I'm making a pool game like game. This game requires correct (or very accurate) reflective bounces. I tried Box2D and Bullet Physics, but they both have this problem. If there is a wall on top of this image, red line is expected course of a real ball in a pool game. But the engines often shows green line course. Especially, This happens after a slowly moving ball hits the wall. Sometimes a rapidly moving ball get slower suddenly. I'm finding a physics engine which can simulate pool game accurately as much as possible without these problems. Can I get some recommendations? Now I'm digging Newton Game Dynamics, but I am not sure the engine will show what I want. I'm considering the PhysX engine as a next trial, and have to make my own if nothing works. But it's obvious it'll take very long time, so I wish I won't do that. I'll be very appreciated if you save my time. And of course, solution with Box2D Bullet Physics are also welcomed. I am working with C C Objective C on iOS. I attach my configuration with Box2D. Walls static box shape linear angular damping 0.1 restitution 1.0 friction 100 density 10 bullet false fixed rotation false inertial scale 1.0 Balls dynamic sphere shape linear angular damping 0.1 restitution 1.0 friction 100 density 20 bullet true fixed rotation false inertial scale 1.0
6
What physics engine support force fields and bodies represented as points? I need a game engine that supports force fields in 2d or 3d, but suitable for 2d calculations, like bullet. Each body I want to simulate is represented as a set of points. Each point has positive mass and can accept force. Force field is updated every tick. Engine should accept force applied to every point and return point speed values and coordinates. Each body made of particles should move as a whole thing in result, relative position of particles must persist, hence this is a rigid body. If engine does not support setting body as a set of points it should allow setting density function, or some other means to let have non uniform density. Is there any that can do that, preferably cross platform.
6
Fixed timestep without physics? I read Gaffer's Fix Your Timestep article many years ago, and have since had the impression that game code should have a fixed timestep, with only non gameplay related tasks outside of that in the main loop. However, I recently reread the article, along with several others, and realized the emphasis is on physics. Which makes sense, but now I'm wondering if it only applies to physics. What about games which don't use a real physics simulation? People talk about 60fps games, doesn't that imply a fixed timestep? What about multiplayer where you have regular updates to and from the server? The only alternative I know of is variable rate with time delta, but that sounds like it wouldn't be any better, and less exact. What method is typically used?
6
How to bounce a 2d point particle off of a circular edge In a prototype I'm building, a particle can spawn anywhere within a larger, confining circle. Important to note is that the particle will not spawn in the origin of the larger circle, but anywhere within it. This particle will essentially be given a random x and y velocity and set on it's way. When the particle hits the edge of the confining circle, I want it to bounce back inwards appropriately. Unfortunately I'm extremely new to vector math, and have never really directly dealt with it before. Given that I'm treating the particle as a point, and I don't care about any loss of force or friction, what should I ultimately do to the particle's x and y velocities after the bounce? I will know the particle's x and y velocity, it's x and y coordinate when it hits the outer circle, the radius of the outer circle, and the x and y coordinates of the origin of the outer circle (since its origin will likely not be 0,0). My brief research on vector math tells me I need to find the normal velocity at the point where the particle hits the outer circle and then negate that, but unfortunately I'm not sure how to do that exactly.
6
Roguelike movement system I'm trying to implement a roguelike movement system for my game. I'm using the ECS architecture. The requirements are entities will have a mass, on which should slow down the entity movement accordingly. fatty ones move slower there will have different terrains, that should apply different friction types, eg ice will decelerate the entity slower a quicksand will almost stop the entity immediately and so on. optionally there will have different weathers that should also impact on the entity movement, eg sandstorm would push the entity to it's direction rains will diminish the friction coefficient a little bit etc... If the two first requirements are solved, the third will probably be as well, I think. How would you do this?
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 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
Physics based rotation with an array of pixels Say I have a simple system, that has a large array of pixels with their own weight, velocity, coordinates etc. (by using classes) if each of those pixels can be connected to 4 other pixels (top, bottom, left, right) how could I let that object rotate, according to physics. An example of this is where I might have an array of pixels that makes a circle, and a slope, if I put the circle at the top of the slope, how would I compute the circle rotating while going down the slope?
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
finding the angle to launch a projectile at a 3d coordinates I have a game where the user can shoot a bullet and the bullet flies through 3 dimensional space and eventually hits the ground somewhere. My question is how can I calculate the pitch of the angle to make the bullet hit a specific coordinates with possibly different elevations. My known factors are The gravity force The initial projectile velocity The shooting position The target position In my case I do not need to factor for target movement, I am trying to make something similar to an artillery weapon that fires into the sky and have the bullet land somewhere else at a target. Because I am trying to make an 'artillery like' weapon I need the weapon to aim up at the sky, not directly at the target.
6
Tracking Object Position Firing on a Trajectory How can I calculate the position of an object after "firing" it from a fixed point? I am to create a small game most likely with canvas (pure HTML, JS based) or Adobe Flash in which the player fires objects at other obstacles in order to clear them.
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
Should I be sharing data between graphics and physics engine in the game? I'm writing the game engine that consists of few modules. Two of them are the graphics engine and the physics engine. I wonder if it's a good solution to share data between them? Two ways (sharing or not) looks like that Without sharing data GraphicsModel some common for graphics and physics data like position some only graphic data like textures and detailed model's verticles that physics doesn't need PhysicsModel some common for graphics and physics data like position some only physics data usually my physics data contains A LOT more informations than graphics data engine3D gt createModel3D(...) physicsEngine gt createModel3D(...) connect graphics and physics data e.g. update graphics model's position when physics model's position will change I see two main problems A lot of redundant data (like two positions for both physics and graphics data) Problem with updating data (I have to manually update graphics data when physics data changes) With sharing data Model some common for graphics and physics data like position GraphicModel public Model some only graphics data like textures and detailed model's verticles that physics doesn't need PhysicsModel public Model some only physics data usually my physics data contains A LOT more informations than graphics data model engine3D gt createModel3D(...) physicsEngine gt assingModel3D( amp model) will cast to PhysicsModel for it's purposes?? when physics changes anything (like position) in model (which it treats like PhysicsModel), the position for graphics data will change as well (because it's the same model) Problems here physicsEngine cannot create new objects, just "assing" existing ones from engine3D (somehow it looks more anti independent for me) Casting data in assingModel3D function physicsEngine and graphicsEngine must be careful they cannot delete data when they don't need them (because second one may need it). But it's rare situation. Moreover, they can just delete the pointer, not the object. Or we can assume that graphicsEngine will delete objects, physicsEngine just pointers to them. Which way is better? Which will produce more problems in the future? I like the second solution more, but I wonder why most graphics and physics engines prefer the first one (maybe because they normally make only graphics or only physics engine and somebody else connect them in the game?). Have they any more hidden pros amp contras?
6
How do I combine multiple squares into one Tetris block? I am learning Phaser by making a simple game mdash Tetris. I'm having difficulties Can I use simple rectangles as tetrominoes or they should be sprites? I don't know how make the figure's block from simple rectangles and apply physics to it. How I can join 4 separate squares into one tetromino?
6
Physics for movement in a topdown 2d game? I'm implementing player movement for a simple topdown game, how would I handle more "advanced" concepts in physics to make my player movement feel more natural? Right now I have something like this void update(double delta) dx dy 0 if (left) dx 1 if (right) dx 1 if (up) dy 1 if (down) dy 1 if (dx ! 0 dy ! 0) x dx delta y dy delta How would I go about implementing things like friction, acceleration, drag, and so on?
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
I'm looking for a paper from Teknikus.dk I'm looking for this great paper about Verlet integration http www.teknikus.dk tj gdc2001.htm I've found this link on many websites, forums, blogs, everyone is recommending it ! The website is down for more than one week.
6
(Fat) ray cast with MPR OR GJK? I know that it's possible to see if a line segment or a swept shape (to make a "fat" line segment) intersects objects using MPR and GJK. Is it possible in those situations to find out the distance down the ray cast that the collision occurred? Thanks!!
6
Will my game engine be compatible with physics engines? My engine supports scene handling, cameras, and has a renderer. Also, it has a class called Drawable, which has the position, the shape and the picture of an object. The picture property has width, height, rotation and a draw method. All game objects are supposed to inherit from this Drawable class, and are added to the scene, along with a map (a collection of Tiles, that also inherit from Drawable), lights, and so on and so forth. The shape property of a Drawable is a Polygon, a collection of user defined vertices around the position of a Drawable. This is a relative coordinate system, so 0, 0 is the position of the Drawable. With this setup, will the users of my engine (which will probably only be me) still be able to integrate physics engines such as Box2DJS into their games?
6
How do I handle moving platforms in a platform game? I don't want to use box2d or anything, I just want simple moving platforms (up down, left right, diagonal and circular paths). My question is to handle the update order control hierarchy so that the player stays fixed to the platform solidly, without bouncing or wobbling?
6
How to implement a slight skid in a car game I have a top down car game, where I'm trying to allow a slight skid I've tried the following code to calculate the X and Y, but there is no skid whatsoever radians rotation Math.PI 180 aX (momentum Math.cos(radians)) aY (momentum Math.sin(radians)) newX playerX aX, newY playerY aY I can get skid by introducing a velocity variable for example radians rotation Math.PI 180 aX (momentum Math.cos(radians)) aY (momentum Math.sin(radians)) velocityX velocityX aX velocityY velocityY aY newX playerX velocityX newY playerY velocityY This introduces far too much skid, like the car is on ice. I've tried reducing the amount I increase the velocity by velocityX velocityX (aX 3) Which sort of works initially, but still ends up ice skating and uncontrollable after playing around for a few minutes. Are there any techniques for introducing a slight skid without this extreme side effect?
6
How to collapse a structure after procedural destruction When considering this temple structure with procedural damage in pink How can I efficiently determine the collapse of such structure as below? Even if the model is defined on a voxel grid, it would still require possibly wide ranging searches for connected ness? In the 2D case, flood filling and labeling disconnected components is probably doable, but what about the 3D case? Can this be done without traversing the entire world space, every frame which I imagine, wrecks havoc to a data cache? Lastly, what is the technical term for this problem of "making stuff fall down after procedural damage?"
6
(Fat) ray cast with MPR OR GJK? I know that it's possible to see if a line segment or a swept shape (to make a "fat" line segment) intersects objects using MPR and GJK. Is it possible in those situations to find out the distance down the ray cast that the collision occurred? Thanks!!
6
Problem with calculating velocity for a car with multiple gear ratios I hope this is the right place for this but I have a problem with calculating velocity for my car game. The higher the gear, and therefore lower the gear ratio, the lower the top speed. Given that Acceleration Forward Force Drag Rolling Resistance Velocity Acceleration dt and Wheel Torque Engine torque Gearbox ratio Differential ratio Forward Force Wheel Torque Wheel Radius I feel like I am missing something because if we decrease the gear ratio we decrease the torque and therefore the forward force causing lower acceleration so the car cannot gain additional velocity, and actually loses it due to resistive forces.
6
How to avoid ai hands or any body part going inside wall or ground? (Unreal Engine4) Whenever my character get killed near wall his hands or any body part its goes through the wall making it look like half of the hands front of wall and another half through back. but i dont like it.. i want it look like modern game where if i killed him near wall it should be realistic where his body part should change posistion according to it. like lifiting his hand because he cant put his hands through wall and also i made a little mistake in my death animation making the hands below the ground so whenever he get killed his hands go through ground.. so how to make this work?
6
A ball hits the corner slightly, where will it deflect? I am currently making an iOS Game but I have a small problem. The game is simply a ball which you can control to avoid obstacles and find the food. When the ball hits, e.g. the top or the bottom of an obstacle, it's easy, the y speed is just inverted. Same with left and right, where the x speed is inverted. But what happens when the mass point of the ball doesn't touch a side of the obstacle, but its surface is? Where will it be deflected? What's the maths behind that? Here's an image to illustrate the problem Thanks in advance for help!
6
Predicting physics trajectory for pool billiards games I'm thinking of making a quick proof of concept of a billiard style game mechanic, where the player has perfect information of what is about to happen. Here's a good example I'm only mildly familiar with physics in both Unity and Flixel Box2D, and I can't really off the top of my head imagine how to do this. Should I even use physics at all, or should I just use basic math?
6
Clothing and physics asset collisions not working I quot m making a character in Blender where there's a character mesh and a simple skirt. The skirt has a different material slot, which allows me to use the Unreal Clothing tool. I created the clothing data, applied it, painted it so the top part isn't moving at all and bottom has 100 quot dynamics quot . I also created a physics asset, however no matter what settings I try, the skirt will always poke through the thighs like they don't exist. All the colliders are capsules. I also get the feeling that the hip collider actually works. But only that one! The skirt works perfectly with the wind, which makes it even weirder. Does anyone know what can cause this?
6
Which Box2D like physics engine parameters need pixel conversion? The official guide does not have any useful details on the matter http www.box2d.org manual.html Position is an obvious one. What about velocity? Density? Anything else? Update the context is wrapping interfacing a physics engine to make it more usable. E.g. units of measure in the game editor should be consistent.
6
how to ignore physics collision of some objects in box2d I know this sounds silly but I would like some objects to follow physics while others not to collide each other. I tried to achieve them by setting their position exclusively. But then it will ignore all physics. Is what I am trying to do even possible?
6
Understanding Tensors I don't seem to be able to visualize tensors. I am reading The Morgan Kauffman Game Physics Engine Development and he uses tensors to represent aerodynamics but he doesn't explain them so I am not really able to visualize them.
6
Should I be sharing data between graphics and physics engine in the game? I'm writing the game engine that consists of few modules. Two of them are the graphics engine and the physics engine. I wonder if it's a good solution to share data between them? Two ways (sharing or not) looks like that Without sharing data GraphicsModel some common for graphics and physics data like position some only graphic data like textures and detailed model's verticles that physics doesn't need PhysicsModel some common for graphics and physics data like position some only physics data usually my physics data contains A LOT more informations than graphics data engine3D gt createModel3D(...) physicsEngine gt createModel3D(...) connect graphics and physics data e.g. update graphics model's position when physics model's position will change I see two main problems A lot of redundant data (like two positions for both physics and graphics data) Problem with updating data (I have to manually update graphics data when physics data changes) With sharing data Model some common for graphics and physics data like position GraphicModel public Model some only graphics data like textures and detailed model's verticles that physics doesn't need PhysicsModel public Model some only physics data usually my physics data contains A LOT more informations than graphics data model engine3D gt createModel3D(...) physicsEngine gt assingModel3D( amp model) will cast to PhysicsModel for it's purposes?? when physics changes anything (like position) in model (which it treats like PhysicsModel), the position for graphics data will change as well (because it's the same model) Problems here physicsEngine cannot create new objects, just "assing" existing ones from engine3D (somehow it looks more anti independent for me) Casting data in assingModel3D function physicsEngine and graphicsEngine must be careful they cannot delete data when they don't need them (because second one may need it). But it's rare situation. Moreover, they can just delete the pointer, not the object. Or we can assume that graphicsEngine will delete objects, physicsEngine just pointers to them. Which way is better? Which will produce more problems in the future? I like the second solution more, but I wonder why most graphics and physics engines prefer the first one (maybe because they normally make only graphics or only physics engine and somebody else connect them in the game?). Have they any more hidden pros amp contras?
6
How do I implement deceleration for the player character? Using delta time with addition and subtraction is easy. player.speed 100 dt However, multiplication and division complicate things a bit. For example, let's say I want the player to double his speed every second. player.speed player.speed 2 dt I can't do this because it'll slow down the player (unless delta time is really high). Division is the same way, except it'll speed things way up. How can I handle multiplication and division with delta time? Edit it looks like my question has confused everyone. I really just wanted to be able to implement deceleration without this horrible mass of code else if speed gt 0 then speed speed 20 dt if speed lt 0 then speed 0 end end if speed lt 0 then speed speed 20 dt if speed gt 0 then speed 0 end end end Because that's way bigger than it needs to be. So far a better solution seems to be speed speed speed whatever number dt
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
how to calculate initial Y velocity required to reach target? I am trying to calculate the y velocity necessary for my player character to jump up and reach a y position within 1 second. Given that my game engine is at 60fps, I am doing velY (targetY playerY) 60 .. However, I need to account for gravity which is being applied to the character on every update, so I am doing velY ((targetY playerY) 60) (gravity 60) This results in the player character always jumping significantly higher than expect. UPDATE Attempting to try the Equations of Motion approach, I am setting a timestamp when the player character should begin moving to the target position... So then in my update loop, I am calling a function with currentTime timestamp. update function(paceFactor) paceFactor in this game engine is how many nominal 60FPS game ticks have elapsed. So if the game is running at 30FPS, then paceFactor will be 2.0, if it's 60FPS, then 1.0 will be passed in. this.timer paceFactor (1 60) if (this.setVelocityAt) this.setVelocityFor(this.timer this.setVelocityAt, this.targetPoint) this.position.x this.vel.x this.speed paceFactor this.position.y this.vel.y this.speed paceFactor this.position.y (gravity (paceFactor paceFactor) 0.5) this.vel.y gravity paceFactor , setVelocityFor function(time, target) if (time gt 1) time 1 this.setVelocityAt undefined this.character.vel.x (target.x this.character.position.x) time this.character.vel.y (target.y (0.5 GRAVITY time time) this.character.position.y) time , Then later the position and gravity is applied to the character as described in the previous update. However, the velocity being set is a huge number which is... wrong.
6
How to move 2D objects based on mouse movement with pointer locking? I'm using pointer locking for a 2D game (where you perform calculations based on the delta in mouse positions from frame to frame). I'm having some basic math logic issues with accomplishing what I want. I'd like the player to be able to send the character in the direction they last moved their mouse (so if they stop moving the mouse, the character continues to travel in the direction they last moved in). The issue I'm experiencing is the movementx and movementy values are integers. If the player moves the mouse quickly so that from one mousemove event to the next many pixels are traversed, the direction to move the character is reasonably precise. Every other scenario results in the last movement having movementx or movementy only being 1 0 1. If the character only moves based on the last movement of the mouse, it very often only moves in one of 8 directions. How can I be more precise than 8 directions even on slow short mouse movements while ensuring the last bit of movement of the mouse is always what's being used? My first thought was to average out the last n movement values, but that can easily result in the character not always moving in the direction the mouse moved last. I've not really had too many other thoughts though, so I came here for assistance.
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
Steer a flock towards a target? Like in pikmin? Can a flock be steered towards a target ? I've seen that flocking behavior has the alignement behavior, but can it be directed and steered toward a goal ? http www.youtube.com watch?feature player detailpage amp v BKJyv4uqsWI t 305
6
How to implement deceleration and stopping over a certain distance So I have a a character, say a spaceship. It needs to move distance R, and in direction T (Theta). So say if The object is at (0,0), and it needs to get to (4,3), it has R 5 and T about 36 degrees. Essentially I know where the endpoint is, and the distance away. I want my spaceship to start decelerating when R becomes 8, and the object come to a halt when it reaches the location. How can I do this. (Kinematics in answers is welcome)
6
game physics contact constraint and relative velocity For two rigidbodies (2D boxes), A and B, I have been colliding A with B and finding the collision normal pointing towards A i.e. the direction that would separate A from B. When it comes to calculating the relative velocity for the contact constraint, does it matter which body has the edge that the collision normal is perpendicular in terms of which velocity to subtract from which?
6
Colliders for moving inside a spaceship when the whole spaceship is made of a single mesh (in Unity) I've begun to study a unity engine in one purpose I have a great multi player game idea! The main essence In space there are two (or even more) huge spaceships with crew consisted of players (all real humans). Ships are very powerful dreadnoughts with a lot of features (radar system, many weapons, missals, refinery factory, gravity generator, indoor light system, shields generators, engines and so on), but all systems are broken at the beginning of the game. Crew should decide, which systems are more important in battle and repair it. They should extract materials from asteroids and revive their spaceship. Then, they should locate second ship, and try to destroy it. Whose spaceship will be in a whole skin during one minute after destroying another, will be the winners. If there are more then two spaceships, surviving crew from destroyed ship can move to another alive ship. I've already draw detailed 3d model of spaceship, but I faced with a problem during importing model to unity. The problem with mesh collider. Players should get into a ship and walking in it, HOW can I do that? I can't use non convex mesh collider in unity 5, and I cannot put one collider to another. It would solve the problem, if I draw ship piece by piece, but not as entire. But ship is really complex, to assembly it from prepared parts take really long time and ship will be messily. Is there another way to solve my problem?
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
Specific path for ai for follow I have an entity's following details x, y vx, vy angle to x axis its target I want to reach the target by a parabolic path, how to implement an ai that follow a particular path from any given point to another like parabolic or sine wave.
6
Should I used Box2D for a Flash platformer or use something for gaming like Fixel or Flashpunk? I'm trying to make a platformer with Flash AS3 and have been looking for something to help with some of the collision etc. I've look at a few engines and Box2D WCK seems the most sophisticated. Do I need that level of sophistication or should I just stick to something simple like Fixel or Flashpunk? OR should I just do everything myself?
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
Lunar lander why is my descent module crashing I've been reading this awesome simulation of the actual Apollo 17 descent http www.braeunig.us apollo LM descent.htm I've been trying to make my own simulation using Euler integration, with a time step of 100ms. The problem is my descent module is crashing during the first two minutes with a vertical speed of 220 m s. During the initial stage of the descent (braking), the lander is tilted 90 and almost all the thrust is spent in the horizontal component, with no force to counter gravity. In my simulation the vertical speed quickly builds up while the pitch is 80 90 , and then gravity does it job. Here's a trace t 0 s x 0 y 17234.6112 vx 1697.1264 m s vy 20.4216 m s ax 1.2995855485404475 m s2 ay 1.6121564579144938 m s2 pitch 90 throttle 0.1297 fuel 8874.2Kg t 10.015 s x 17062.974621379497 y 16948.14950433809 vx 1710.2669538608811 m s vy 36.64853435841286 m s ax 1.3247309786564347 m s2 ay 1.628484797082333 m s2 pitch 90 throttle 0.1297 fuel 8855.501190599978Kg t 20.019 s x 34239.89169813059 y 16498.912567960208 vx 1723.6514116543285 m s vy 53.026163503416676 m s ax 1.3509707026458686 m s2 ay 1.6456786784409965 m s2 pitch 90 throttle 0.1297 fuel 8836.82291908347Kg t 30.026 s x 51527.03405575163 y 15884.74450896862 vx 1725.5675762461628 m s vy 69.5834660661016 m s ax 0.9584923539027193 m s2 ay 1.663174744204344 m s2 pitch 90 throttle 1 fuel 8756.011226046036Kg t 40.041 s x 68759.3217349438 y 15103.315677459259 vx 1715.7571868391299 m s vy 86.32821281208818 m s ax 1.0003892381595199 m s2 ay 1.6806337716945954 m s2 pitch 90 throttle 1 fuel 8611.841531365935Kg t 50.502 s x 86651.75776002374 y 14107.047450672597 vx 1705.0564069549016 m s vy 104.00697912916615 m s ax 1.0452064683102156 m s2 ay 1.6991809596193168 m s2 pitch 90 throttle 1 fuel 8461.251498809865Kg t 134.865 s x 226365.92349700694 y 5.915270639694082 vx 1602.384872970266 m s vy 225.9485740506923 m s ax 1.382111636427434 m s2 ay 1.224439728661491 m s2 pitch 78 throttle 1 fuel 7246.814359289593Kg FINISHED at t 2.24775 minutes However, in the original simulation, vertical speed never exceeds 20 m s. I don't know how could this be possible, as there's no drag due to atmosphere. And I've coded initial acceleration and velocity values exactly as in this very same page. You can check the original trace here http www.braeunig.us apollo LM descent.pdf Here we can see the Moon's gravity is aprox. 1.5 m s which heavily influences ay in my simulation. However in the real descent trace it was kept to lower values ( 0.1) most of the time, even during the first minute when there was no vertical thrust due to the engine. I must be making very stupid mistakes but right now I can't see where. BTW this is how I update my vars in each step Calculate acceleration as a function of mass, velocity, thrust and gravity ax vx vx (y MOON MEAN RADIUS M) (thrust x mass) ay (vx vy (y MOON MEAN RADIUS M)) g (thrust y mass) This would be the acceleration for a flat moon. Don't work either. ax thrust x mass ay g (thrust y mass) Update velocity as a function of acceleration and time. vx vx ax dtSecs vy vy ay dtSecs Update position x x vx dtSecs y y vy dtSecs Any hint would be appreciated. Thanks in advance.
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
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
3D Physics in Marmalade SDK I am trying to make an 3d game in Marmalade. I am completely new to Marmalade. How to add 3d physics, gravity, dynamic object, sensors, colliders in Marmalade. I was going through the API and did not find anything. Can you guys let me know how to accomplish these things
6
Confused about calculation of steering force I'm reading Programming Game AI by Example, by Mat Buckland. What I don't understand there is why the individual behaviors return a vector representing change in velocity, but the combined result is treated as a force vector. Here's the excerpt from the update function Vector2D SteeringForce m pSteering gt Calculate() Acceleration Force Mass Vector2D acceleration SteeringForce m dMass update velocity m vVelocity acceleration time elapsed make sure vehicle does not exceed maximum velocity m vVelocity.Truncate(m dMaxSpeed) update the position m vPos m vVelocity time elapsed And m pSteering gt Calculate() returns the weighted sum of different steering "forces", like Seek Vector2D SteeringBehavior Seek(Vector2D TargetPos) Vector2D DesiredVelocity Vec2DNormalize(TargetPos m pVehicle gt Pos()) m pVehicle gt MaxSpeed() return (DesiredVelocity m pVehicle gt Velocity()) So, how come steering functions like Seek just return change in velocity and don't take mass into account, but still get used as force? Here's the source code
6
Car movement in arcade racing game I am finishing a very basic 2D racing game with top down perspective. I can't get the appropriate formulas to make the movement of the cars fun and addictive... Do you have tips on how to achieve that arcade feeling a lot of games have? Do you know of any guide tutorial on this topic? Right now, these are the formulas I am using (speed changes linearly according to the user input) direction turnAmount.Value Vector3 pos Position new Vector3(speed.Value (float)Math.Cos(direction), 0, speed.Value (float)Math.Sin(direction)) I have tested other, more complex options but this is the best I have got so far...
6
How can I recreate the movement of arrow in air? Given two Particles A and B which forms the arrow itself, A.P an edge of it and the opposite one B.P. Like so A.P B.P. const float DistArrow 60 Where I have structure Particle struct Particle struct Complex P Position struct Complex F Gravitational Force struct Complex V Velocity float m Mass At the start each particle, A and B has a starting Velocity of like (40, 70). And I am adding a value of force to A.F(0, 9.21) and B.F(0, 9.81). So that the B.F has much more weight on it, so it drags the A to down kind of. I want the arrow to move like this And I am tried to figure out how to make till I was stuck with this(I am trying to calibrate in a way the arrow to the initial DistArrow A erA gt B (D(AB) DistArrow) 2 A where erA gt B(unit vector) (B A)D(AB) B erB gt A (D(AB) DistArrow) 2 A where erB gt A(unit vector) (A B)D(AB) The problem is that it just rotates 180 degree, dunno why it does, if it will infinitely fall it should be A at the top of B, a line perpendicular with oX. I am seeking a good solution not involving to much physics, any advice will be highly appreciated.
6
What are the parameters for btHingeConstraint setLimit? What does each parameter in btHingeConstraint setLimit do to the hinge constraint? void btHingeConstraint setLimit ( btScalar low, btScalar high, btScalar softness 0.9f, btScalar biasFactor 0.3f, btScalar relaxationFactor 1.0f )
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
Collisions between sprites in SpriteKit I'm making a game in XCode using SpriteKit. The game has a player and different types of projectiles that he has to avoid. When the player collides with the projectiles, the score changes and the projectile disappears. However, when two projectiles collide, they kind of bounce away. I want to make that every time two projectiles collide, they act like nothing happened and they keep going in their original path. What should I do? Note This is not the whole code, it's just what matters. import SpriteKit struct Physics static let player UInt32 1 static let missileOne UInt32 2 static let missileTwo UInt32 3 class GameScene SKScene, SKPhysicsContactDelegate var player SKSpriteNode(imageNamed "p1.png") override func didMoveToView(view SKView) physicsWorld.contactDelegate self player.position CGPointMake(self.size.width 2, self.size.height 5) player.physicsBody SKPhysicsBody(rectangleOfSize player.size) player.physicsBody?.affectedByGravity false player.physicsBody?.dynamic false player.physicsBody?.categoryBitMask Physics.player player.physicsBody?.collisionBitMask Physics.missileOne player.physicsBody?.collisionBitMask Physics.missileTwo var missileOneTimer NSTimer.scheduledTimerWithTimeInterval(1, target self, selector Selector("SpawnMissileOne"), userInfo nil, repeats true) var missileTwoTimer NSTimer.scheduledTimerWithTimeInterval(1.2, target self, selector Selector("SpawnMissileTwo"), userInfo nil, repeats true) self.addChild(player) When contact happens func didBeginContact(contact SKPhysicsContact) var firstBody SKPhysicsBody contact.bodyA var secondBody SKPhysicsBody contact.bodyB if ((firstBody.categoryBitMask Physics.player) amp amp (secondBody.categoryBitMask Physics.missileOne)) CollisionWithMissileOne(firstBody.node as SKSpriteNode, missileOne secondBody.node as SKSpriteNode) else if ((firstBody.categoryBitMask Physics.player) amp amp (secondBody.categoryBitMask Physics.missileTwo)) CollisionWithMissileTwo(firstBody.node as SKSpriteNode, missileTwo secondBody.node as SKSpriteNode) else if ((firstBody.categoryBitMask Physics.missileOne) amp amp (secondBody.categoryBitMask Physics.missileTwo)) CollisionBetweenMissiles(firstBody.node as SKSpriteNode, missileTwo secondBody.node as SKSpriteNode) For Player and MissileOne func CollisionWithMissileOne(player SKSpriteNode, missileOne SKSpriteNode) missileOne.removeFromParent() For Player and MissileTwo func CollisionWithMissileOne(player SKSpriteNode, missileTwo SKSpriteNode) missileTwo.removeFromParent() For MissileOne and MissileTwo func CollisionBetweenMissiles(missileOne SKSpriteNode, missileTwo SKSpriteNode) ???WHAT SHOULD I CODE HERE???
6
Help interpreting the physics of a rolling ball I'm using this article for reference. I understand handling the collision aspect, but I can't figure out how to calculate the new velocity once the ball collides with the ramp. Without it the ball just slides down the slope and stops at the bottom, with no horizontal velocity generated from the descent. The equation mentioned is tangentialVelocity velocity (velocity normal)normal Which I've tried as ball.velocityX magnitude ( magnitude normalX) normalX ball.velocityY magnitude ( magnitude normalY) normalY to no avail. Here is what I've done so far, which finds how far the ball is intersecting in the ramp and moves it outside. var distance int FP.distance(circleWorld.x, circleWorld.y, ball.x, ball.y) var penetration int distance ball.radius worldRadius if ( penetration gt 0) var componentX int circleWorld.x ball.x var componentY int circleWorld.y ball.y var normalX Number componentX distance var normalY Number componentY distance ball.x normalX penetration ball.y normalY penetration
6
How are physical model programmed in simulation games? Being a Gran Turismo fan, I'm wondering what are the algorithms used to compute realistic behavior for friction, aerodynamism, velocity, curves etc. Also, are there sophisticated ways to simulate fluid mechanics in flight simulation which are trivial enough for an amateur project ? If I wanted to build a flight simulator, neglecting the parameters which have the littlest effect (temperature, pressure, humidity, friction of the air on the wings, gravitational center of the plane, etc), are there some kind of physical formulae or programming models I should know about ? Or does physics engine feature such kind of simulation dedicated calculation ?
6
Creating shattering effects without having to use actual physics? For certain effects like glass shattering and falling objects cracking to reveal their inner contents, are there any tricks or ways to implement these fracture physics without having to use actual physics simulation? Also, what are the trade offs if I don't use real physics simulations? Since the effects don't really require exact simulation, an actual physics simulation may be too expensive and wasteful.
6
How can I add an impulse to specific rigid bodies at rest? Scenario Rocks falling down a rocky slope, with a flat surface at the bottom. When they land on the surface, the rocks move slightly before coming to a rest. GLESDebugDraw shows the bright orange outline turning to a slightly darker orange once a rock comes to a rest, until the rock is agitated by another falling rock. Question I would like to add an impulse to the rock once it reaches the rest state. How would I implement that?
6
Moving CCNode with constant speed in cocos2d I want to move the object (CCNODE) with constant speed in any direction , what i have did till now is applied a force to object at start to get it moving and set elasticity as 1 and friction as 0 to every object which it will collide . After some time speed goes on increasing , is there any way so i can check if speed increased so that i can control it or to apply velocity instead of force . Thanks !
6
Writing an autopilot for a 2d game with newtonian physics The subject says it all. I am making a 2d space game with newtonian physics and I need pointers on how to write an autopilot for it. The requirements are best explained by an example. There is a target object which has speed and position vectors and there is a spaceship that is controlled by the autopilot. This spaceship also has speed, position and maximum acceleration. The autopilot needs to control the ship so that it either collides with the target or intercepts the target with matching speed and position. Could someone give me some pointers how to achieve this behavior or perhaps even a ready implementation? I am sure someone has written something like this before and there is no point in reinventing the wheel.
6
Pathfollowing with acceleration centripetal force I'm implementing A waypoint pathfinding with some twists. One of the problems I'm encountering is because I do not change velocities of the agents directly but rather I do so through forces. Which gives me the following problem let's suppose the path consists of three nodes, P0 the starting position P1 node 1 P2 node 2 When the agent starts moving, it's first target position is P1. The agents moves in that direction because I let a force F act on it's velocity F normalized(targetPos agentPos) agentAccel agentMass The agent reaches P1. Now the agent's target position is P2, and upon it will act a force in the direction of (targetPos agentPos). However, this is a centripetal force, meaning that the agent will most likely orbit around P2 instead of popping the next node off the path (unless the angle between P0,P1 and P1,P2 is small) Stopping the agent at each node is not an option (would look unnatural) What should really happen is the velocity of the agent gradually shifting towards 100 the direction of targetPos agentPos , and the velocity should be completely 'shifted' before a certain distance(dX) is laid off, starting from the previous node position In order to solve this problem, only one parameter is adjustable F dir the direction of the force acting upon the agent, that's supposed to lead the agent to the next node. The values of the following parameters are known agentAcceleration ( the magnitude of the force vector) agentVelocity agentPosition node positions targetPosition ( the next node on the path) I've been trying some different strategies with trial and error to prevent this, but it seemed rather messy, so my question is, what is a decent approach to this problem?
6
Sliding loose dirt shader material effect Im sure there is some sort of technique with a name I don't know or didn't think to search, but how would I go about making an effect similar to loose dirt sliding down the face of a slope when something disturbs it? I guess I think of it as a mini avalanche or something. I have attempted it a couple times with pretty poor results, but some of the properties i tried to replicate was the sliding dirt spreads out the further it gets from its start position depending on the surface shape, angle of repose, rocks or larger pieces of debris causing even more dirt to slide(quasi recursion?), loose dirt 'sliding' over other dirt, etc. I assume id need to combine the right ratio of shaders, particles and textures to look right but I cant seem to find any real info on this type of effect. Would something like this be too intensive to do real time?
6
Should a bowling game use a 2d or a 3d physics engine? I'm creating a bowling game in flash as3. I'm new to physics engines, so, to start I've begun to learn Box2D since I've heard it's one of the most popular physics game engines. Currently, I'm not sure if it's the best solution. I'm not sure even if I should use a 2D physics engine or if I should move to 3D physics engine. As you can see in the attached screenshot of my game, the ball should move on the lane until it hits the pins. The game has some amount of 3D behavior. Please advise.
6
Ideas for 2D Water Simulation I am looking for any input on simulating water in 2D, against a rather large (call it) blocked not blocked array (viewed from the side). I have come up with the following ideas Cell Automata Do a massively parralel simulation on the CPU, using cell automata. With rules as simple as If there is a cell open to the bottom move to it. Check the left and right cells, choose a random one out of the two and move to it. Pros Simple to implement. Meaningful deterministic in a multiplayer system. Cons Probably really slow. Not convincing. Fluid Dynamics on the GPU Perform a rough approximation of fluid dynamics on the GPU against a texture like the following R G B A vX vY NULL Density Pros Probably really fast. Could be quite convincing. A further pixel shader could render it directly. Cons Difficult to implement. Difficult to tweak. I can't allocate a single texture the size of my level. I could overlap the grid areas, but this would add further complexity. Particles Use particles to simulate the water. During rendering using additive blending and then apply a multiplication function to the alpha channel to give the water crisp edges. Pros Will probably look nice. Easy to implement. Easy to render. Meaningful in a multiplayer system, although would require quite a bit of bandwidth to transfer. Cons Inter particle effects will probably be slow (neighborhood lookup). Could lead to water 'leaking' through solid spaces (because the solid space is small, e.g. 1px). Could lead to strange holes in the water depending on the particle size. Both of the above could be mitigated by allowing particles to drift closer together than their real size, however would cause problems with the inter particle and particle landscape performance. Any further ideas? Note This is an approximation, I am not looking for physically correct water here just something that 'is good enough' (bonus points for quick and dirty). The game is multiplayer, so unfortunately the whole level needs to be simulated continuously.
6
Physics based dynamic audio generation in games I wonder if it is possible to generate audio dynamically without any (!) audio assets, using pure mathematics physics and some input values like material properties and spatial distribution of content in scene space. What I have in mind is something like a scene, with concrete floor, wooden table and glass on it. Now let's assume force pushes the glass towards the edge of table and then the glass falls onto the floor and shatters. The near realistic glass destruction itself would be possible using voxels and good physics engine, but what about the sound the glass makes while shattering? I believe there is a way to generate that sound, because physics of sound is fairly known these days, but how computationaly costy that would be? Consumer hardware or supercomputers? Do any of you know some good resources videos of such an experiment?
6
Will my game engine be compatible with physics engines? My engine supports scene handling, cameras, and has a renderer. Also, it has a class called Drawable, which has the position, the shape and the picture of an object. The picture property has width, height, rotation and a draw method. All game objects are supposed to inherit from this Drawable class, and are added to the scene, along with a map (a collection of Tiles, that also inherit from Drawable), lights, and so on and so forth. The shape property of a Drawable is a Polygon, a collection of user defined vertices around the position of a Drawable. This is a relative coordinate system, so 0, 0 is the position of the Drawable. With this setup, will the users of my engine (which will probably only be me) still be able to integrate physics engines such as Box2DJS into their games?
6
How can I simulate a rigid body bounced from a wall in 3D world? How can I simulate a rigid sword bounced from a wall and hit the ground (like in physical world)? I want to use this for a simple animation. I can detect the figure and the size of the sword (maybe needed in doing bounce). Rotation can be controlled by quaternions matrix euler angles. It should turn the head and do rotations and fly to the ground. How can I simulate this physical process? Maybe what I need is an equation and some parameters? I need these data, and would combine them into my movie file, I use Mathematica to do the thing that generate the movie file(If I have the data, I can also export it into a 3DSMax script for example).
6
How do I detect ledges? In my game, I'd like my character to be able to grab and hold onto ledges, and to be able to pull themselves up if there's room to do so. How do I detect if there's a ledge, and if the character has enough space to climb up?
6
How to collapse a structure after procedural destruction When considering this temple structure with procedural damage in pink How can I efficiently determine the collapse of such structure as below? Even if the model is defined on a voxel grid, it would still require possibly wide ranging searches for connected ness? In the 2D case, flood filling and labeling disconnected components is probably doable, but what about the 3D case? Can this be done without traversing the entire world space, every frame which I imagine, wrecks havoc to a data cache? Lastly, what is the technical term for this problem of "making stuff fall down after procedural damage?"
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
What is your Unity 3D physics engine budget for iOS games? I'm testing Unity for a game that I'm building, and I've touched its limit. My test scenario a wanna be house with 200 elements (cubes rescaled) no textures, box colliders and rigid bodies for each "cube" and fixed joints to hold them together (400 fixed joints). The house is on a plane, and above it I put 2 sphere at different altitudes, spheres which will crash in the poor house. This moves very slow on an iPod Touch 3rd generation. Therefore I'm looking for some documentation to create a reasonable budget for the number of polygons, physics collisions and so on. What is your recommendation?