Ludum Dare 31
December 5th-8th, 2014

October Challenge 2014
Ending Soon!

ConstructionPlease excuse the site weirdness. Mike is making and fixing things. Clocks are probably wrong. Colors are place-holder.

What is Ludum Dare?
Rules / Guide

The failure of Newton

Posted by
August 21st, 2010 3:35 pm
Space mess

Space mess

So far, I implemented the usual Newtonian physics, that is, the ship has a thurster control, which makes it accelerate in the current direction, and speed and position are integrated from it.

To control by hand, it’s a bit unusual, but we get used pretty fast. Especially since I coded a control that turns you automatically to the direction opposite to your speed, so you can “slow down”.

However, I’m stuggling to build an AI for something as simple as “go there and stop”. The easy way seems to be to first slow down to a stop, then turn to the point, accelerate half the way, deccelerate half the way. But that, of course, fails if the target is moving.

More naive solutions can work too, but they all seem to “diverge” in that if you aim at a fixed point, the ship will oscilate around it, on an increasing orbit.

Anyway, despite allowing for pretty nifty curvy trajectories, I’m affraid Newtonian physics are actually not fun. You almost never point at where you want to go, and you spend your time doing “straight” accel/deccel trajectories, because they are easier to visualize.

The solution I see is to go back to a more “arcade” system, where the player controls directly speed, instead of acceleration. Pressing the thruster button makes you go forward, period. Of course, in space it’s very impossible, but that’s the kind of behavior we are use to on Earth. Thanks to friction on the floor, cars, bikes and stuff are controled by direction.

On the other hand, I like the idea that you can aim at somewhere you don’t go, especially if weapons are aligned with the ship. That way you can do fly-by shootings, and looking around without actually moving erraticly.

Maybe I can try a hybrid system, where ships have proper Newtonian inertia, but as soon as the thrusters are on, the speed is fixed to the forward direction. Maybe also some sort of damping to avoid brutal speed jumps then.

Dunno. I’m getting tired and I haven’t done much yet. Also I’m far from any game at all.

Tags:


One Response to “The failure of Newton”

  1. Covenant says:

    You can cheat on the AI, using feedback loops… I’ve done so in the past with lots of success on that same context…
    Feedback loops use the following piece of code:

    Error=Target-Current
    Current=Current+Error*epsilon

    The farther away from epsilon is from 1, the slower the movement will be… This will make objects start very fast and slow down at the desired trajectory…
    What I used to do was to apply this to the angle/trajectory of the ship (she would turn very fast in the beginning, but I compensated with a “dynamic epsilon” factor related to the value of the error), and then get smoother and smoother… works very well for ships that pursue other ships, etc…
    I’d adjust thrust in terms of how far it is from the target (further away, more thrust, which means wider curves, and how much the ship has to curve).
    It also helped targeting not the player ship but a point in front of it (for pursuit kind of behavior)…
    Hope this helps…

Leave a Reply

You must be logged in to post a comment.

[cache: storing page]