Hot answers tagged

4

Physics done on the GPU are usually cosmetic effects. Particles are a good example, but hair and tall grass are similar. The GPU is very good at doing a massive number of calculations and since it also handles the drawing if these things it is a good match. A GPU isn't very fast at communicating the results back to the CPU. This is why physics used in ...


4

The solution is to abandon your concept of dtpercent. To make it framerate independent deltatime between frames is all you need. Framerate 60 fps: dt will be 0.016 miliseconds with a framerate of 30 this value will be 0.032 miliseconds. Thus have everything based on the dt and scale your simulation units to 'x per second' and things will run framerate ...


3

Methods of creating vehicle physics changes dramatically from game to game. Often, as you have suggested, they focus on the body of the car and leaving the wheels as visual. The way I suggest going about this is using this system as a prototype, play around with what it can do and find the limitations, such as wheels clipping through uneven planes. This ...


2

It s a bit unclear what you are asking, in particular what you mean by "gametic". A computer game re-paints the screen repeatedly. Between two re-paints you have a delta time T, typically 0.01...0.03 s. Say it is 0.02 s this time - note however that it fluctuates. Then you can calculate the physics & movement over a single calculation, to which you ...


2

I think you mean that the trajectory (the direction it is traveling) does not change, such that the ball bounces perfectly up and down between the two same points on the parallel plates. You are correct that this is extremely difficult and nearly impossible in real world conditions, because there are so many factors that can alter the ball's path. However, ...


2

This is a straightforward application of the Unit Circle, multiplied by the length of the vector we want as output: x = length * cos(angle) y = length * sin(angle)


2

You're essentially swapping the axes x and y, going from horizontal play to vertical play. Along those lines, try swapping the axes in your bounce code. All the x variables become y and all the y variables become x (i.e. ball.y -> ball.x). Width and height swap as well. Specifically, that method would look like this: player_interesected_ball = ...


2

Parameterized equations of (2D) motion for a parabola are as follows: x = x0 + t * Vx y = y0 + t * Vy - 0.5 * g * t^2 with a sign convention of increasing X rightward, increasing Y upward. These are a simple adaptation of the kinematic equations of motion under constant acceleration.


2

I think you can't do it. Phaser groups doesn't have body: http://phaser.io/docs/2.4.4/Phaser.Group But you can use setAll method to set properties to all sprites of a group: http://phaser.io/docs/2.4.4/Phaser.Group.html#setAll Otherwise, if you want more complex objects you could try another type of physics (P2) and make complex bodies with polygons.


2

You can fix this problem by averaging the initial and final velocity: velocityOld = velocityX velocityX += acceleration * delta; posX += (velocityX + velocityOld)/2 * delta; In this particular example it will completely remove dependancy on delta. In general this solution will reduce the effect of delta.


1

I found the problem while modifying my code to try out Jon's sugestions. Somehow I added a max distance of 5 to the RayCast. Must have gotten confused with the many overloads or something. It works if I modify the second line like this: if (!Physics.Raycast (transform.position, new Vector3 (0, -50, 0), out hit/*, 5*/)) {


1

I have been unable to find a default way to achieve what I had in mind, so I ended up using a variant of what was explained in Sparckman's YouTube video, called Indiana Jones - Falling Through Platforms - Tutorial. I'm afraid that I had to delete the link, in order to be able to post a picture. See below. The trick was to group the lines handling player ...


1

There's going to be some variation in how you approach this, depending on whether you're going for "pixel-perfect retro re-creation" or "playable prototype to learn about making platformers." You don't need perfect precision to make something fun, so there's nothing wrong with taking a simpler route, especially in your early work. As I go through the steps ...


1

Your mathematics simply fail at some point. Consider this case: The particle is 0.00000000000001 units from the center. Apparently it should rotate 1000000000 times around the center, given the speed it has, and given your iteration time for this re-calculation. Move it a little bit out, to 0.0000001 units from center. Now it should only rotate 10000 times ...


1

I havent done much on these lines. But every object should recive (time_elapsed) and calculate new position accordingly. They should check for possible collision with static objects, and react (change of direction / state). As far as other closer moving objects, you will have to do some hack (either treat the slower one as static, or get its ...


1

In nutshell your a movement would look something like this: speedX speedY for vertical and horizontal speed. You have a velocityX and velocityY for example. Lets say its a top down game. And you have your positions like posX and posY. Every tick you update your positions: posX += speedX; posY += speedY; You assing a value to velocity like 0.2. In you ...


1

You could take a look at how phaser debug works: https://github.com/photonstorm/phaser/blob/v2.4.2/src/physics/p2/BodyDebug.js On line 90 you have the 'draw' function that shows you how phaser draw the shapes. If you take a look at the last part of the function you can have a way to get the verts of the polygons of each shape: verts = []; vrot = p2.vec2....


1

I dug into this some more and have come to the following understanding. I'm open to be corrected though, so if anyone knows more, please chime in. For now though, this is what I think is going on. rigidbody.inertiaTensor contains the diagonalized elements of the inertia tensor or the principle moments of inertia. These correspond to some internal symmetry ...



Only top voted, non community-wiki answers of a minimum length are eligible