rickbatka / co-op-engine

A prototype engine for our planned co-op game. This is where we will make it work, make it network, and make it feel fun. No AI, level design, etc.
2 stars 0 forks source link

Global speed limit is too... limiting? #24

Closed rickbatka closed 10 years ago

rickbatka commented 10 years ago

Went to implement weapon knockback, and I was having trouble getting a fast knockback. Realized all movement is clamped to global movement speed limit, also realized that everything walking around right now is basically moving at that speed limit.

Because of the way physics code is written, this means nothing can move faster than the player walking speed.

we need per-object speeds, but really, we probably need per-object-per-state speed limits. I hacked in a temporary speed limit increase for weapon knockback, but it won't allow for variable knockback for stronger attacks or anything like that.

It feels pretty hacky to say, oh I need a strong knockback, let's adjust the speed limit for a few MS and then set it back after knockback is done.

Moving on to other stuff, but this needs more thought.

reddenx commented 10 years ago

this is a major part of the refactoring physics I want to do, ultimately there shouldn't be a speed limit, the friction force should limit against your movement force so you reach a terminal velocity, so when you are knocked back, all you do is apply an impulse force to object, and it goes flying, but then slows quickly as friction slows it back down, I had a simple little game demo that did this pretty well. The hard part is getting the balance between force and friction to make a reasonably adjustable and stable system to work with, complicating this is coming up with a decent force application equation that increases resistance as velocity increases.

reddenx commented 10 years ago

Minor change done, one step closer to goal, Idea, make friction and velocity settable and have helper methods that we can feed max velocity and acceleration which would set them.

rickbatka commented 10 years ago

I'd really like to know sooner than later if the physics are going to change. We should finish tweaking this and set it in stone. There are a LOT of mechanics that rely on physics not changing out from underneath them, and the more features we implement, the worse it would be to want to change movement physics.

reddenx commented 10 years ago

Yes they are going to change, it will be the very next thing I work on. I've been distracted by the animation and compiler project.

reddenx commented 10 years ago

So I've come to the conclusion while running through a bunch of models on paper (still no workstation) that we really should use a model that involves mass with fixed gravity, we don't have to use the actual numbers but I was thinking about a predefined set of numbers like tiny small medium large and immovable obejcts, we could also do the same with friction, and provide several helper methods to set all the under the hood variables. The end result would be something like this:

public void SetPhysicsAttributes(MassEnum, Acceleration, MaxVelocity)

and possibly a more tuned one for very special objects

SetPhyscsAttributed(MassFloat, FrictionCoefficient, Gravity = defaultGravityValue)

This would give us great flexibility AND the ability to still treat it as a simple engine:

V += c / (V - Vmax) broken down from V += a a = F/m F = Finput - Ffriction Ffriction = Mu * Fn Fn = m * g

where we provide Vmax, Mu, g, and m

(somehow I'll have to sneak in timescaling into it to avoid framerate differentials)

rickbatka commented 10 years ago

I like the idea of the different mass presets. We should take great care to use them in lieu of custom values whenever possible in the game so it has a very concise, exact feel. The last thing I want is a physics simulator. I also imagine our friction setting will be tuned high (like it is now) so that we provide high amounts of impulse force, high amounts of accel, and get slowed down extremely quickly.

Can't speak to the equation, I'll take the approach of playtesting and judging it then :smile:

reddenx commented 10 years ago

Woot complete, no mass but we have a 3 parameter sliding adjustment: friction, maxVelocity, force