WANTED - Bullet Curve

It would be cool to make a script that allows you to curve bullet, like over the corner and shit…

  1. Idea.
  • Slow mo, you see bullet how it curves.
  1. Idea.
  • Slow mo, camera follows bullet.
  1. Idea.
  • Setting destination for the bullet.
  1. Idea.
  • Slow mo and camera follows the bullet only with successful kill.

It would be very useful and fun!

If it’s not possible, then it will be very difficult, and I don’t think much people would be up for making it. And I can’t see how it would be useful in any way, sorry.

It’s very possible.

This would be pretty epic for making Wanted machinimas.


Though the movie sucked :c

Take a look at this thread: http://www.facepunch.com/showthread.php?t=767853

In particular, Robbis made one I think:

Robbis’ attempt was pretty poor (no offence Robbis), It didn’t work very well. I think the best way to go about this is to use some sort of parabolic equation with the final gradient the same as the initial gradient.

This is probably the equation I would use:

y(x) = y0 + m*x - (m-n)x^2/2*L

m is the initial gradient of the curve,
n is the final gradient of the curve,
L is the length of the parabola,
x is the distance along the parabola,
y is the height of the parabola at x.
y0 is the inital height of the parabola.


L could be calculated like this:

L= 2*(v^2)*sin(2*ang)/g

L is the length,
v is the initial velocity,
ang is the angle of release,
g is the gravitational constant (-9.81)


I’m not sure how to go about using that in 3D space though.


I might have a go at this later using a Catmull-Rom spline, I already have the code for the curve and the derivative of the curve (for the direction of velocity), I would just need to make a physics bullet entity and apply it to that.


I just downloaded Robbis’ Wanted SWEP, It is actually different to the one I used. It works quite well.

If anyone is interested, I have made a start on this.
I’ve decided to use a Quadratic Bezier curve to do this.


The white lines are just for debugging the construction of the curve, the red line is the curve that the bullet will follow.

I will post a video of this later.


I haven’t started the slow mo or the bullet camera yet though.

Looks good!

Null, do you know how to make the camera follow the bullet? I’ve been experimenting with that, but since the bullet doesn’t really exists as an entity to be followed I’m at a loss as to what to do.

My bullet does exist as an entity, but you could have a mess around with calcview?

Yeah, I was trying with CalcView but unsucessfully. Oh well.

Are you doing any curving, or just straight bullets?

It was just straight bullets at the time, but the problem was that once the camera started following the bullet, if I tried to remove the hook or override it on impact nothing seemed to happen.

i dont think you will get the slo mo

I can already do the slo mo in singleplayer.

I have basically finished this, The bullets follow the curve perfectly and slow motion bullet cam works (It isn’t slow motion in multiplayer for obvious reasons). I will start uploading a video to youtube and hopefully it will be done when I get back from University (:argh: slow upload speeds).

Nice bro!

I’d like to see how you made your debugger :smiley:

The Bezier Curve?


[lua]function math.QuadraticBezier(p1, p2, p3)
return function(t)
t = math.Clamp(t, 0, 1);
return (1-t)(1-t)p1
+ 2
+ t

function math.QuadraticBezier3D(p1, p2, p3)
local x = math.QuadraticBezier(p1.x, p2.x, p3.x);
local y = math.QuadraticBezier(p1.y, p2.y, p3.y);
local z = math.QuadraticBezier(p1.z, p2.z, p3.z);
return function(t)
return Vector(x(t), y(t), z(t));

local laser = Material(“cable/redlaser”);
hook.Add(“PostDrawOpaqueRenderables”, “DrawCurve”, function()
if not GetGlobalBool(“drawCurve”) then return; end
local p1 = GetGlobalVector(“p1”);
local p2 = GetGlobalVector(“p2”);
local p3 = GetGlobalVector(“p3”);
if p1 and p2 and p3 then
local spline = math.QuadraticBezier3D(p1, p2, p3);
debugoverlay.Cross(p1, 16, FrameTime());
debugoverlay.Line(p1, p2, FrameTime());
debugoverlay.Cross(p2, 16, FrameTime());
debugoverlay.Line(p2, p3, FrameTime());
debugoverlay.Cross(p3, 16, FrameTime());
render.AddBeam(spline(0), 3, 0, color_white);
for i=0, 40, 1 do
render.AddBeam(spline(i/40), 3, 0, color_white);
render.AddBeam(spline(1), 3, 0, color_white);

Just how you got the lines to show and bend, thats what I need to continue work on my npc ai. I couldn’t ever figure out how to draw them.