Idea: Open Vehicle Base SENT

I’ve been wondering for a while why no vehicle base-ents have been released, so I’m wondering if anyone is interested in something like this…

Basically, what I want to do is make an ENT that can load models up, animate them, and allow for scripted driving. I know vehicles are already implemented in Source, but frankly, I don’t like them (for several reasons). A scripted vehicle ent would allow for greater customization & could be pretty smooth in online-play.

I’d want to release it in the public domain - the sole purpose of the project would be to make it easy for people to implement vehicles in gamemodes. So that means I don’t want anyone to be hassled with crediting people, asking for permission, etc (just like we don’t credit Garry or Valve when we release scripts)

So right now I’m just gauging interest, wondering if anyone has any ideas, willing to listen to criticism if anyone thinks it’s a shit idea.

I already have some experience with vehicles, having made VMod way back in the GMod 8 days, so I can take an in-depth look at vehicle models, how they work, and how they can be better implemented in LUA. I’d like to start with basic stuff like cars, then add support for aircraft, then water vehicles, and finally misc stuff like amphibious vehicles, jetpacks, mechs, etc

I’m already working on multiple projects so I’m not starting this just yet (but maybe soon). If anyone wants to donate code (if you’re willing to surrender it to the public domain), that would sure as hell get things going quickly. I’ll post any progress made on it, but it’ll def be good to discuss it before diving in.

“base_vehicle” was never fully finished. There isn’t a high demand for vehicles either, although there should be. When you make guns the focal point of the game, and leave every other element alone, you destroy balance.

Then again every 9 year old on doesn’t care about any of that. They just want a “supr cuool gam”.

My advice? Create a project site on Google Code. Start working, don’t stop. Get a good foundation, then show us work. Make sure to implement the methods like Get/SetScriptedVehicle which were designed for this sort of thing.

I think this is a great idea. Continue on with it(, don’t stop). I’d love to donate code, and can help you out with this. Right now I’m creating a SWEP pack to please the kiddies, but on the side, I have concepts unwritten for vehicles you can shoot in, and so forth.

Sounds like a great idea, but I’m terrible with SENTs, I can never get them to do what I want them to :frowning:

I like the idea but when it comes to aircraft, the Gyropod and Advanced Gyropod from SBEP already have them covered (along with engine mod and fin).

Either way we need more vehicle SENTs, so go for it!

I’d love to see this done, there is a great lacking of good vehicle based gamemodes.

You’re a fantastic designer, I’m sure you could push yourself to make something excellent provided if you really wanted/needed to.


I must also add that if you wish for it to be worthwhile, you should research car movement. Please don’t slap up a generic ApplyForceOffset. A good engineer will use a decent thought-out system for friction and acceleration, and so forth.

I know what you mean. I do want a lot of flexibility in configuring handling. I also want to keep in mind that some people will want to make racing-sim gamemodes, while others will want to make arcadey kart-racing gamemodes, & each will need very different handling styles.

When I was working on VMod, I had to script every little detail of each vehicle, and I learned a lot from that. But it’s complicated… The movement code is something I can see myself rewriting many times before I have something everyone’s really satisfied with, & that’s fine.

Even if aircraft have been implemented before, it’s still different from what I’m aiming for - this is for developers, specifically for them to use freely without any permission needed, without any strings attached whatsoever.

Even more reason why you should go ahead and do it.

When you are going to implement it, make it lightweight. So don’t overload it with five billion options you can set which now have to be checked in e.g. PhysicsSimulate so a server might begin to lag.

I can just support this idea for a base-vehicle SENT which allows setting a model, max speed, acceleration, steering range, a few gears (simulated by sound only to keep it simple) and done.

Actually, let me add, that if you’re seriously going to make this a refined base entity. Base it off the Source SDK.

Seriously. Then you might even be able to take vehicle scripts, convert the key values, and load up a scripted entity that way.

It’s how I’ve written derived-based stuff in the past, and it’s the best way to go about it.

I have a feeling that basing it too much on SDK vehicles would make them rather complicated (maybe even intimidating to amateurs, which I also don’t want)

Most likely, the more complicated it gets, the less of them can be simultaneously present without lag. I can already foresee a divide on how to handle that - some people would prefer a few elaborately scripted vehicles, and others would be fine with simplistic controls, as long as a packed server can remain stable with dozens of them.

Could probably have it both ways. I think it would be possible to make a very basic base ent, and then a simplistic base-land-vehicle derived from it (which would be very slimmed down, so many could be present. probably not very realistic, probably great for kart racing modes), and then a more advanced base-land-vehicle derived from that (which would be based on SDK vehicles, feature-packed but possibly a lot more laggy).

But it’s probably best to start with the simplest stuff & work from there. Hopefully I’ll be able to get started on something in the next few days… still need to finish my Fretta contest entry & finish a bunch of boring/paid work.

You’re going to have a lot of difficulty finding a balance between slippery ass vehicles (Garry Theft Auto) and unrealistic go-kart physics.

I wish you luck :frowning:

Why find a balance when you can have both, like he said?

The balance is the hard part.

I made a base vehicle a while back, but all it did was slide on the ground. It was like a bathtub sent that you could drive. I never added friction though. I’ll upload it really quick.



include( “shared.lua” )

function ENT:Draw()


AddCSLuaFile( “cl_init.lua” )
AddCSLuaFile( “shared.lua” )
include( “shared.lua” )

function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
if ply.HasScrEnt then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 16
–local SpawnAng = ( SpawnPos - ply:GetPos() ):Angle().y
local bathtub = ents.Create( “bathtub” )
bathtub:SetPos( SpawnPos )
–bathtub:SetAngles( Angle( 0, 0, SpawnAng ) )
bathtub.owner = ply
ply:Spectate( OBS_MODE_CHASE )
ply:SpectateEntity( bathtub )
ply:DrawViewModel( false )
ply:DrawWorldModel( false )
ply:PrintMessage(3, “You are now a bathtub!”)
ply.HasScrEnt = true
return bathtub

function ENT:Initialize()
self:SetModel( “models/props_interiors/BathTub01a.mdl” )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self.Entity:GetPhysicsObject():SetMaterial( “Ice” )
self.ply = self.Entity.owner

function ENT:Think()
if ( !self.ply:IsValid() ) then self:Remove() return end

if self.ply:KeyDown( IN_USE ) or !self.ply:Alive() then
	self.ply:SetCollisionGroup( COLLISION_GROUP_PLAYER )
	self.ply:SetMoveType( MOVETYPE_WALK )
	self.ply.HasScrEnt = false
self.ply:SetPos( self:GetPos() )

local phys = self.Entity:GetPhysicsObject():Wake()


function ENT:OnRemove()
if self.ply then
self.ply:SetCollisionGroup( COLLISION_GROUP_PLAYER )
self.ply:SetMoveType( MOVETYPE_WALK )
self.ply.HasScrEnt = false

function ENT:GetPlyForwardAcceleration( driver )
if (!driver or !driver:IsValid()) then return 0 end

if ( driver:KeyDown( IN_FORWARD ) ) then return 50 end
if ( driver:KeyDown( IN_BACK ) ) then return -50 end

return 0


function ENT:GetPlyTurnYaw( driver )
if ( !driver or !driver:IsValid() ) then return 0 end

if ( driver:KeyDown( IN_MOVELEFT ) ) then return 10 end
if ( driver:KeyDown( IN_MOVERIGHT ) ) then return -10 end

return 0


function ENT:PhysicsSimulate( phys, deltatime )
–[[ If we’re not on the floor then don’t do nothin
if !self.Entity:IsOnGround() then

-- Make sure we're the right way up!
local up = phys:GetAngle():Up()
if ( up.z < 0.33 ) then

local forward = 0
local right = 0
local Velocity = phys:GetVelocity()
local ForwardVel = phys:GetAngle():Forward():Dot( Velocity )
local RightVel = phys:GetAngle():Right():Dot( Velocity )

if ( self.ply ) then
	forward = self:GetPlyForwardAcceleration( self.ply )
	yaw		= self:GetPlyTurnYaw( self.ply )

-- Kill any sidewards movement (unless we're skidding)
right = RightVel * 0.95

-- Apply some ground friction of our own
forward = forward - ForwardVel * 0.01

local Linear = ( Vector( forward, right, 0 ) ) * deltatime * 1000

-- Do angle changing stuff.
local AngleVel = phys:GetAngleVelocity()
-- This simulates the friction of the tires
local AngleFriction = AngleVel * -0.1

local Angular = (AngleFriction + Vector( 0, 0, yaw )) * deltatime * 1000

-- Note: Local Acceleration means that the values are applied to the object locally
-- ie, forward is whatever firection the entity is facing. This is perfect for a car
-- but if you're making a ball that you're spectating and pushing in the direction
-- that you're facing you'll want to override this whole function and use global
return Angular, Linear, SIM_LOCAL_ACCELERATION


ENT.Type = “anim”

ENT.PrintName = “BathTub”
ENT.Author = “Rob PC Camp”
ENT.Contact = “”

ENT.Spawnable = true
ENT.AdminSpawnable = true

I think some of that code is from the unfinished vehicle base, I don’t remember. lol

If you do this I will support you as much as I can.
I’ve always wanted properly scripted vehicles, but was always put off by quite how complicated the code would be to have them behave properly (ie actually be things with wheels that allow forward/back movement (with turning!) but not side to side, but have the rest of the model not do this etc).
(PS air vehicles are far easier because they don’t have specific contact points with unique physical properties, which is why there are a lot of them made.)

Yea I’ll get around to something really cool like a worthog later. lol

Well, for a side note, the wheels are all handled with pose parameters, and could really be handled with four traces starting at where the axle would be. Set the matching parameter there.

The turning is controlled through the steer pose parameter ( which does both wheels ), and the spinning of the wheel ( visually ) is done through the wheel’s appropriate pose parameter.

However, that’s about where the simpleness ends since the model viewer doesn’t expand the combo box, so the wide parameters like the ones on vehicles aren’t shown completely.

Also, I don’t know if the pose parameters adjust the collisions or not, so that would take some testing.

This looks awesome. Just wanted to say that first.

Could we have vehicles with weapons? Like a tank that (bet you never saw this coming…) can fire its turret? I know this is possible thanks to sakarias88’s flying vehicle SEnts, but I’ve never seen it done outside of that.


Would be useful.