Git Product home page Git Product logo

tork's Introduction

Tork

An arcade vehicle system for Unity

Intro

Tork is not meant to be a realistic vehicle physics solution. It is best deployed in games where driving realism, especially at high velocities, is secondary. For example, demolition derby style games or games where driving is a secondary gameplay element. You could probably get away using it in a parking game.

Tork has its own Wheel physics component simply called TorkWheel which provides a greatly simplified friction computation mechanism. There are only three tweakable parametes: forward grip, sideways grip and rolling friction.

It provides spring customization which is quite similar to the inbuilt WheelCollider in Unity.

TorkWheel also provides recommended values and guidelines for tweaking values.

Components

Vehicle is the central class. It stores instances of all the Core and AddOn components in the car and this provides a single point for accessing these components. Vehicle class doesn't have any features of it's own and only facilitates in access.

Core

TorkWheel

A simplified version of Unity's Wheel Collider. Much of the information of this is in the Intro section above.

Ackermann

Tork uses Ackermann steering to turn the wheels in a realistic manner.

Motor

Essentially the engine of the vehicle. Has a maxTorque field that determines the maximum torque it can deliver. It also distributes it among the wheels smartly using the Ackermann component of the vehicle. Currently it only supports All Wheel Drive with other modes coming soon.

Value is the normalized value of the engines output. So .5 would mean the engine is creating maxTorque/2 torque.

maxReverseInput is the highest negative value the engine will output. This is because engines usually reverse at and up to a lower speed.

Brakes

Very similar to Motor except that it applies braking torque on the wheels. Please see source to see the similarities.

Steering

A layer of added feature over Ackermann. It stores the maximum steer angle the Ackermann will be sent as well as the rate at which the steering happens.

Add Ons

AddOns are scripts that can be used to add or modify the vehicles behaviour. These derive from VehicleAddOn so that Vehicle can store them in a list and provide GetAddOn<T>() a method that allows any consumer to access the add on by type.

The add ons shipped with Tork are

CenterOfMassAssigner

Assigns the center of mass of the vehicle. It is to be attached on a GameObject that represents the center of mass. You'd pretty much always need this class. Use it to make sure your center of mass is lower else the vehicle will flip on sharp turns.

AntiRoll

Vehicles in real life also have anti roll bars that try to keep the vehicle grounded based on the difference in compression of the horizontally opposite wheels. So when you're taking a sharp right turn, the anti roll bars help ensure you don't flip the car anti-clockwise (to the left).

DownForceVsSpeed

Applies a down force on the car to simulate better aerodynamics. You'd normally want a linear curve

MidAirStabilization

A pretty arcadish feature that tries to ensure that the vehicle lands flat on the ground. When the vehicle is in the air it applies counter torque based on the orientation.

MidAirStabilization

Another arcasish feature that allows the vehicle to be steered in air.

MaxSteerAndleVsSpeed

Used to mimic real life driving by changing the max angle by which the wheels will rotate. Unless you're a bad driver, you won't steer the wheels all the way at high speeds and flip it. This class simulates that.

TorkWheelViewSync

Synchronises the wheel meshes with the rotation and position of their respective TorkWheel objects.

Ideas

Many, many addons can be made. Some ideas I have: A BrakeLights that makes the tail lamps illuminate. SteeringWheelSync that rotates the wheel along with the steering input.

Input

The way input is provided and handled by the code and add on scripts may change, especially because it's like that as more add ons accumulate, it'd be good to make it available for reading some a common place. For now IVehicleDriver interface is to be extended. KeyboardVehicleDriver is inbuilt in Tork.

Demo

A demo scene and script is provided inside Tork/Samples/

Forks

For a DOTS implementation of Tork v1, check out @PragneshRathod901's fork

Contact

@github
@www
@npm

tork's People

Contributors

samserious25 avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tork's Issues

Adding skidmarks

I've noticed Tork doesn't use the standard WheelColliders. How hard is it to implement/convert a skidmark script that normally uses the standard WheelColliders?

RPM calculating

Hello qnd thanx for your physics, it is great!

I usi rpm of wheels to make engine sound work. So it is possible eith unity's wheel colliders, but in Tork there is no rpm var on wheel.

So how can I get rpm?

Build Issues

Hello,

The project fails to build in the latest Unity version with the following errors:

Build completed with a result of 'Failed'
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun() (at /home/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindow.cs:123)

UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x00269] in /home/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:191
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in /home/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:95
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun() (at /home/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindow.cs:123)

Unity version: 2019.3.6f1
OS: Linux Mint

Sincerely,
Marino

WheelRenderer wrong angle

Hello,

In the WheelRenderer class there's a problem calculating the angle over the wheel velocity. The velocity vector is in world coordinates so it changes depending the direction of the wheel.

If you don't mind I'll create a Pull request to solve this issue.

Cheers

Hi Adrenak, can you give me a hint/ small problem

Hi Adrenak, I really like your car physics implementation, carefully elaborated and comprehensible - I even tried to modify some parts.
but recently I stumbled on the Jittering issue. On my project all other scripts work by FixedUpdate and Time.deltaTime everywhere. and alone Tork works with Update+Time.deltaTime.
I've searched all over Core-folder scripts but still can't find out how to change to (FixedUpdate and Time.deltaTime). if you have time, can you point out where to look? thank you very much.

za2

Sliding at low speeds on angled surfaces.

@adrenak , do you have any thoughts on this one?

With "Fake Normals" set to OFF, there seems to be a lot of lateral sliding. Even with brakes on.
Any ideas? Thanks again for all your hard work on this project!

slidingWheels

Unused variable

Hello @adrenak

I just noticed there's a warning on the AntiRoll class.

The variable 'hit' is declared but never used

More accurate collisions/ Multi RayCast

Hi @adrenak,

Thanks for sharing this project! Really great work!

I was thinking of developing the wheel collider code to handle multiple raycasts per wheel (many more radiating from the center). How do you think this would work with the wheel script? I mean it looks like the wheel script is designed to only handle one hit point. Thanks for any thoughts on this!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.