• Create Account

# KurtO

Member Since 05 Dec 2011
Offline Last Active Jul 30 2015 04:10 PM

### Collision routine - push or precalculate velocity or oldpos / safepos

30 July 2015 - 04:10 PM

Hi.

I am pretty confused about what routine to take when trying to create a 2d scroller game.

I want to use a rectangle as bounding box and i want to have all kinds of angles and rotating objects, elevetors etc.

right now i like "the move -> get penetration delta ->push back" concept, this is the one i get to be stable without jittering. And with recursive checks this works great in small corners etc. Also other moving objects "pushes" the player for "free"

If i try to sweep and get the TOI and change the velocity to sliding for example, this always gives me jitters and jerkiness.

The same with the oldPos vs newPos when saving position and then check for collisions and if found, then revert back to the safe position. This i also get jitters when implement. Should i still be doing the "push-back" even if i calculate the TOI?

What is the "standard" way of doing when creating a FPS in 3D and in my example 2D scroller.

The problem with the push right now is that i get sliding from the gravity vector even though my velocity is set to zero, this is due to the pushback vector. So this is why i want to try something new, otherwise i really like that technique.

And if you were to do a 2D scroller with different angles for floors, would you use AABB and then line intersection?

I am checking the minkowskis sum, but i think there might be simpler stuff for the scroller.

I am stuck with prototyping right now and cant get progress, so any input is helpful =)

### Am i missing something, can i sweep like this?

28 July 2015 - 02:48 PM

Hi.

I am thinking of a way to sweep polygons and rectangles against another polygon and get the Time of Impact.

If i draw lines between the vertexes startposition and endpositionof the polygon (or rectangle) and test those lines for intersections of the other polygon (or rectangle).  If i then take the intersection point and compare it to the length of that line, that will give me time of impact.

It has of course be the earliest time of impact compared with all the intersections.

Can i really do it like this? It would be great, because then i can only do line-line intersection test between the vectexes of the shapes.

i submitted a file to illustrate this better.

I am using a sphere in my game now, and i dont think it works with my character.

### 2D scroll game gravity problem with "slide" and "update after collision...

25 July 2015 - 04:23 PM

Hi!

I am almost finished with my 2D engine that supports polygons with all angles.

the way i do collision detection is:

move();

update() //pushed the players out again if there was some penetration that was not permitted (this is done recursivly with the smallest TOI first)

everything works great, BUT

one small thing is if my player is standing on a very small hill, he continues to slide very very small distance in the x-axis.

this is becuase the gravity vector is always added and the the player is being pushed down, and with the corrections it is resulting with a movement..

The way i slide is this:

var dotN = current_pushvector.dot(game.player.vVel);
game.player.vVel.x -= (current_pushvector.x * dotN);
game.player.vVel.y -= (current_pushvector.y * dotN);

But this is wrong for 2D scrollers i think.

What kind of collision response do you do on 2D scrollers?

### Capsule line intersectionpoint only

24 July 2015 - 05:44 AM

Hi

I have made a capsule by making two circles and two lines between them (on the edges)

I use lineintersection and closest point to find out if the capsule intersects any lines, this works perfect and i get the intersectionpoint on the lines and where the closest point to the sphere is.

My problem is, i cannot get the circles intersectionpoint with radius. I have tried cutting velocity according to distance etc but its only working 95% correctish.

Is it possible to get the circle intersection from the capsule intersection point?

### Frustrating climb and descent energy (velocity)

01 March 2015 - 03:59 AM

I have a problem with my flight model. I miss the part with velocity acceleration during descent and extra drag during climb.

I have implemented Drag curve and Lift curve against these formulas. And it works really good. I only miss the extra energy (kinetic) when descending and loss of energy when climbing.

Iam not sure i have understood the resulting drag/acc to the models and cant find good resources on this.

I have attached an image to see if i have understood this correct.

Do you know if this is the correct approach?

My lift function

// L = Lift in Newton.
// P = Airdensity kg / m3
// V = velocity in m/s
// S = Wingarea m2
// Cl = Lift Coefficient - Angle of Attack lookup table (99% it is devided by ten)
// L = (P / 2) * V^2 * Cl * S
var L = (this.getCurrentAirDensity() / 2) * Math.pow(this.getVelocity(), 2) * this.getCoefficcientValue(ClCurve) * this.wingarea;

return L;

My drag function

// D = Drag
// P = Airdensity kg / m3
// V = velocity in m/s
// S = Wingarea m2
// Cd = Drag Coefficient - Angle of Attack lookup table (99% it is devided by ten)
// D = Cd * S * 0.5 * P * V^2
var D = this.getCoefficcientValue(ClDrag) * this.wingarea * 0.5 * this.getCurrentAirDensity() * Math.pow(this.getVelocity(), 2);
return D;

PARTNERS