New answers tagged

0

the methods you're looking for are: setAngularDamping(float damping); setLinearDamping(float damping); according to cocos2d-x documentation both methods are used to simulate fluid or air friction forces on the body.


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*/)) {


0

The way you'll do it really depends on the kind of game you want to make. If you want to achieve a realistic behaviour, you'll have to start by modeling nearly the whole car, with a decent physics engine. If you want to achieve a more casual feel (games like MarioKart), you'll have to simplify a lot of things. In any case, you'll have to fake some ...


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 ...


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 ...


-1

The accepted answer can be found at Animate Sprite Along a Curve path in XNA I appreciate the help people have tried to post. static float mFlightTime = 0.0f; Vector2 mVelocity = new Vector2(-12, -8); Vector2 mAcceleration = new Vector2(0f, 1f); Vector2 mStartingPosition = new Vector2(260.0f, 31.0f); Vector2 mPosition = Vector2.Zero; public void update(...


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.


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 ...


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, ...


0

In general, approach B is actually faster since it can be cached and vectoried more efficiently using Structs of Arrays (SoA) / Arrays of Structs of Arrays (AoSoA), which you probably should be using anyway.


0

Engines aside, circle collision is incredibly easy to program - you can do it from scratch. Every circle object must have a Vec2d position value and a radius. In your update loop, iterate through your list of all circles and then test to see if any pos value of one, >= the pos of any other, + both radiai. If this is true, stop the gravity force from acting ...


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 = ...


0

You can easily do this with trigonometry. The ball bounces off from the paddle in 90 degrees if it hits the exact center of the paddle and in 45 degrees, if it hits the edges of it. This means, that the ball can bounce from the paddle between -45 and 45 degrees, in radians, this is -PI/8 -> PI / 8. Now you need to map each point of the paddle between ...


0

I'm actually working on a 2D project similar to what your doing, definitely less complex in scope though. I am also a beginner at this but can give you what I've learned so far. You're going to need to figure out your gravity mechanics first, universe generation is easier and will have to come second. Since I'm assuming you're making a game and not a ...


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 ...


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.


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....


0

You have only four independent co-ordinates to track: The location of the center-of-mass, as the vector (x, y); the separation of the two point masses as the scalar d; and the orientation of the masses about the center-of-mass, as the scalar theta. plus their rate of change over time: (Vx, Vy), v, and w Don't attempt to analyze any forces - just use ...


0

@eldo's answer is good, but since you are doing this from scratch, you need to begin implementing systems for physics. There are all manner of ways to do this, from implementing a quadtree of physical space (so you're only checking sections that your moving object will pass through), to implementing colliders like Unity does (and I believe Unreal Engine has ...


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 ...


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 ...


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 ...


0

Unity had a Character Controller for this exact reason. It works very well for 3D, and should translate just fine to 2.5D.


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

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 ...



Top 50 recent answers are included