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

[editline]02:31PM[/editline]

Though the movie sucked :c

In particular, Robbis made one I think:
http://solidfiles.com/info_imgs/8wTn.jpg

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

``````

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

[editline]02:07PM[/editline]

L could be calculated like this:

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

``````

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

[editline]02:07PM[/editline]

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

[editline]02:09PM[/editline]

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.

[editline]02:20PM[/editline]

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.

[editline]04:00PM[/editline]

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!

The Bezier Curve?

[editline]11:03AM[/editline]

return function(t)
t = math.Clamp(t, 0, 1);
return (1-t)(1-t)p1
+ 2
(1-t)tp2
+ t
t*p3;
end
end

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));
end
end

local laser = Material(“cable/redlaser”);
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.SetMaterial(laser);
render.StartBeam(42);