Setting up custom collider.kn5 & colliders.ini

Everything about modding.
Post Reply
User avatar
Tunari
Site Admin
Posts: 44
Joined: Fri May 19, 2023 11:47 am
Location: Finngolia
IQ rating: 89
iRating: 2545

Setting up custom collider.kn5 & colliders.ini

Post by Tunari »

AC collisions suck. There is not much you can do about them, but you can mitigate the problem by at least having your colliders set up properly.
The KN5 collider is used by ground collisions, wall collisions and car contact collisions.

Prerequisites:
  • Blender3D
  • Basic knowledge of Blender controls.
  • Kseditor
  • CM with developer mode enabled.
  • A car
The car we will be working with is my friends 300C. The collider is from the Formula K, so the car behaves funnily when you drive it around.
2023-05-21_10-53-12.jpg
2023-05-21_10-53-12.jpg (286.61 KiB) Viewed 3522 times
Step 0. Extract the KN5 to get a reference for the shape of the car, and import it to blender.
2023-05-21_10-53-52.png
2023-05-21_10-53-52.png (115.83 KiB) Viewed 3522 times
Step 1. Create a box in the origin of the scene and scale it around to fit roughly the bounds of the car.
2023-05-21_10-57-00.jpg
2023-05-21_10-57-00.jpg (61.84 KiB) Viewed 3522 times
Step 2. Block out a basic shape of the car. Do not make it too detailed and make sure the model is manifold. (waterproof, no holes)
2023-05-21_10-59-08.jpg
2023-05-21_10-59-08.jpg (72.51 KiB) Viewed 3522 times
Step 3. The alignment.
Because different 3D programs use different notations for the axises, at some point in the pipeline from FBX to AC, the model gets rotated 90 degrees. This is why colliders come out wonky/incorrectly rotated at times. To counter this, do:
First rotate the collider model -90 degrees on the X axis. CTRL + A to apply rotation transform. Also apply scale transform, if you have those.
Then rotate the model +90 degrees on the X axis. Your collider model should now have origin 0,0,0 rotation 90,0,0 and scale 1,1,1. Your collider should now export with the correct alignment.
2023-05-21_10-59-32.png
2023-05-21_10-59-32.png (125.41 KiB) Viewed 3522 times
Step 4. Add material. The material name can be whatever you want.
2023-05-21_10-59-56.png
2023-05-21_10-59-56.png (40.17 KiB) Viewed 3522 times
Step 5. Exporting and kseditor.
Use these export settings and everything should go fine. MAKE SURE YOUR COLLIDER OBJECT IS THE ONLY SELECTED OBJECT IN YOUR SCENE (ORANGE WIREFRAME).
2023-05-21_11-01-29.png
2023-05-21_11-01-29.png (13.98 KiB) Viewed 3522 times
In Kseditor make the collider object active and select material GL.
2023-05-21_11-02-18.png
2023-05-21_11-02-18.png (45.3 KiB) Viewed 3522 times
Export KN5 (car) and name it collider.kn5

Step 6. Complete(?)
If you have worked with a Kunos pipeline compliant car that has been aligned correctly, this is where the guide ends. Your collider lines up with the car in CM, everything is fine. (Do note, that basey and visual offset rotation in car.ini may affect the rake of your collision model.)

As you can see the collider shape has changed from the last time we saw it. But it appears something is not adding up! My friend Tes has been slipping and has not aligned the car to be above 0 cordinate on the Y axis!!!!
2023-05-21_11-04-19.jpg
2023-05-21_11-04-19.jpg (206.78 KiB) Viewed 3522 times
So the collider turns out slammed to the ground, as the collider function in AC always assumes the model is correctly aligned above the 0 cordinate.
This is a simple fix:
Re-open Blender (you DID save your blend, RIGHT?)
Select all (press A twice) and drag everything up until the tire lines up with the green axis. After this, Apply the location transform (CTRL + A). DO NOT APPLY ROTATION OR SCALE AGAIN.
After this, repeat instructions in step 5.
2023-05-21_11-15-28.png
2023-05-21_11-15-28.png (64.88 KiB) Viewed 3522 times
Now you should have a working 3d collider! And it only took you 1 hour and 32 minutes.
2023-05-21_11-21-18.jpg
2023-05-21_11-21-18.jpg (169.22 KiB) Viewed 3522 times
Colliders.ini

Colliders.ini are simple box colliders that only collide with road surfaces. These are useful for things like collisions for front splitters, diffusers, or squat-plates.
For a simple road car application, just make the collider span the general bounds of the floor of the car. Collider thickness does not need to be more than 0.1.
Image
Image
Image
Image
Image
ImageImage
ImageImageImage
User avatar
Tunari
Site Admin
Posts: 44
Joined: Fri May 19, 2023 11:47 am
Location: Finngolia
IQ rating: 89
iRating: 2545

Re: Setting up custom collider.kn5 & colliders.ini

Post by Tunari »

Collider alignment troubleshoot
fordgt-collider.png
fordgt-collider.png (311.5 KiB) Viewed 3486 times

Problem: Collider comes out rotated 90 degrees the wrong way, despite looking fine in kseditor.

If you meshed out your own collider, this should not be a problem, however if you used the convex hull modifier method from Tes' tutorial, you may encounter the following: Delta transforms.
In simple terms: When an object has a child, and it is rotated, the children do not technically get transformed. However they still move along with the parent, so they get a delta transform. Chances are, that if you have imported a kn5->fbx file, your objects may have deltas.
deltas.png
deltas.png (38.67 KiB) Viewed 3486 times
This is thankfully a simple fix.
In Blender 2.8, just press CTRL + A -> APPLY ALL TRANSFORMS. Then re-apply rotation transform by following step 3 in the guide, if you need to. :mrgreen:

In Blender legacy (2.79b), the tools for handling deltas are very primitive.
In 3D view, make sure the T menu is open (lefthand side panel), then make sure your object is active and clear transforms with ALT-G (position), ALT-R (rotation), ALT-S (scale). In the lefthand side panel, make sure to click the CLEAR DELTA tickbox for each time you press the binds. :idea:
transform-apply.png
transform-apply.png (43.44 KiB) Viewed 3486 times
Image
Image
Image
Image
Image
ImageImage
ImageImageImage
Post Reply