Car Rig WIP *TUTORIAL*

Hey everyone, I’ve recently put together a car rig which seems to work in most non-extreme cases. However one thing that’s missing is automated inertial braking and accelerating.

I need access to the second derivative of an fcurve, and I’ve scoured the internet for snippets of code.

What I’ve come up with is a piece of code which adds a new function to the driver namespace. It evaluates the difference between the fcurve value at preceding frames, then evaluates the difference between the difference at preceding frames.

Basically it calculates the second derivative on a frame by frame basis. It works fine in the example .blend attached, but fails when applied to the final rig. Perhaps I haven’t tried hard enough, but I’m quite certain that if a skilled coder could have a look at this piece of code, they will find ways to improve it.

Here’s the .blend file: INERTIA EXAMPLE
To use the .blend file, all you need to do is run the script in the text editor, and update dependencies in the drivers window. The animation should then work correctly.

Here is a video of the car rig at the moment:

https://youtu.be/H96cxh2JbMM

import bpy

#rename the following variables to suit your scene


frame = bpy.data.scenes['Scene'].frame_current
fcurve = bpy.data.actions['ArmatureAction'].fcurves[0]
df = 1


def f1(frame):
    t1 = fcurve.evaluate(frame-df)
    t2 = fcurve.evaluate(frame)
    
    return (t2-t1)


def deriv(frame): 
     return (f1(frame)-f1(frame-df))
 
print(deriv)
bpy.app.driver_namespace["deriv"] = deriv



TUTORIAL:

Maybe we can use tire deformation

i already commented this on youtube… but turns out would rather post here
i am working on a car right now and i need a rig…, i had plans to learn it and all but i’m just going to watch the tutorial if you make one… the thing i was planing to do with my rig was basically make a braking system… such that either the back or front tires stop moving instantly like applied handbrake in scenes of drift… i don’t currently see such thing in yours though but you have all the other functionalities there such as ground detection and all so its cool. better than any other car rig i’ve seen so far.

I can’t think of any way to achieve that which wouldn’t require some basic scripting (I’m not very skilled at all in this area)

Update: I’ve managed to implement automatic braking/accelerating inertial shift using some hacky coding. Here’s a quick rendered result:

OK so I rebuilt the rig from scratch and implemented a cloth-based suspension (idea from this Tiger Tank Rig). I’m currently looking at ways to allow for drifting, since it’s a bit tricky at the moment. But nonetheless, the suspension is working great now!

Here’s where it’s currently at:

tre beau. Very beautiful. Great work so far man. Appears very acurate

Alrighty here we go. I consider this rig complete. Drift control works, suspension system is working great, and the whole thing is quite simple to set up. Expect a tutorial within the next two weeks :smiley:

That looks great! I look forward to the tutorial :slight_smile:

Really nice rig. I’m also looking forward to seeing your tutorial.

Very awesome. I’m more focused on organic modeling at the moment, but will definitely check out your tutorial the minute I find out it’s posted. :slight_smile:

your rig makes animating a car seem so easy haha. Most brilliant rig i’ve seen in blender!

Well, boys said everything up here, so i will just continue with my waiting for tutorial. Your work is great!

A tutorial also!? You sir, are a saint! lol

Really awesome, waiting for the tut, this will help me return to rigging again :slight_smile:

Tutorial is done and ready! Here you go:

Thanks you for all the effort you put in, this will be helpful for a lot of us here ;).

Thanks very much for the tutorial. It’s a great reference for your new car rig. I’ve also been looking at your earlier videos too. Very helpful, thank you.