Skip to content

Commit

Permalink
feat: Remove input stuff.
Browse files Browse the repository at this point in the history
Add Rigidbody accessor to Vehicle class
  • Loading branch information
Vatsal Ambastha committed May 2, 2020
1 parent 0fee076 commit 97f4eba
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 193 deletions.
15 changes: 15 additions & 0 deletions Assets/Tork/Runtime/Core/Motor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

namespace Adrenak.Tork {
public class Motor : MonoBehaviour {
[SerializeField] float idleRPM;

[Tooltip("The maximum torque that the motor generates")]
public float maxTorque = 10000;

Expand All @@ -11,10 +13,14 @@ public class Motor : MonoBehaviour {

public float m_MaxReverseInput = -.5f;

[SerializeField] float rpmReadonly;
public float RPM { get { return rpmReadonly; } }

public Ackermann ackermann;

void FixedUpdate() {
ApplyMotorTorque();
CalculateEngineRPM();
}

void Update() {
Expand Down Expand Up @@ -45,5 +51,14 @@ public class Motor : MonoBehaviour {
ackermann.RearRightWheel.MotorTorque = value * maxTorque * rs;
}
}

void CalculateEngineRPM() {
var sum = ackermann.FrontLeftWheel.RPM;
sum += ackermann.FrontRightWheel.RPM;
sum += ackermann.RearLeftWheel.RPM;
sum += ackermann.RearRightWheel.RPM;

rpmReadonly = idleRPM + sum;
}
}
}
8 changes: 0 additions & 8 deletions Assets/Tork/Runtime/Input.meta

This file was deleted.

7 changes: 0 additions & 7 deletions Assets/Tork/Runtime/Input/IVehicleDriver.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Assets/Tork/Runtime/Input/IVehicleDriver.cs.meta

This file was deleted.

28 changes: 0 additions & 28 deletions Assets/Tork/Runtime/Input/KeyboardVehicleDriver.cs

This file was deleted.

12 changes: 10 additions & 2 deletions Assets/Tork/Runtime/Vehicle.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using UnityEngine;
using System.Linq;
using UnityEngine;
using System.Collections.Generic;

namespace Adrenak.Tork {
public class Vehicle : MonoBehaviour {
[SerializeField] Rigidbody rigidbody;
public Rigidbody Rigidbody { get { return rigidbody; } }

[Header("Core Components")]
[SerializeField] Ackermann ackermann;
public Ackermann Ackermann { get { return ackermann; } }
Expand All @@ -16,10 +20,14 @@ public class Vehicle : MonoBehaviour {
[SerializeField] Brakes brake;
public Brakes Brake { get { return brake; } }

[Header("Add On Components")]
[Header("Add On Components (Populated on Awake)")]
[SerializeField] List<VehicleAddOn> addOns;
public List<VehicleAddOn> AddOns { get { return addOns; } }

void Awake() {
addOns = GetComponentsInChildren<VehicleAddOn>().ToList();
}

public T GetAddOn<T>() where T : VehicleAddOn {
foreach (var addOn in addOns)
if (addOn is T)
Expand Down
8 changes: 4 additions & 4 deletions Assets/Tork/Runtime/Viz/WheelViz.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using UnityEngine;
using UnityEditor;

using UnityEngine;
using UnityEditor;

namespace Adrenak.Tork {
public class WheelViz : MonoBehaviour {
[SerializeField] TorkWheel target;
Expand All @@ -21,4 +21,4 @@ public class WheelViz : MonoBehaviour {
Handles.DrawWireDisc(pos, t.right, target.radius);
}
}
}
}
75 changes: 7 additions & 68 deletions Assets/Tork/Samples/Prefabs/Tocus.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 255152389}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 04ba35be00207f1408fcd9d4f9881aaf, type: 3}
m_Name:
Expand Down Expand Up @@ -675,19 +675,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1da1bb9a22dc0004c803629affe1f6df, type: 3}
m_Name:
m_EditorClassIdentifier:
rigidbody: {fileID: 54767532765438496}
ackermann: {fileID: 1214198106228332029}
steering: {fileID: 1214198107381208202}
motor: {fileID: 1214198106513114726}
brake: {fileID: 1214198106157320312}
addOns:
- {fileID: 1214198107650998328}
- {fileID: 1214198107889706808}
- {fileID: 1214198106422026516}
- {fileID: 1214198107628456250}
- {fileID: 1214198106691927564}
- {fileID: 1530015582167757396}
- {fileID: 4502441065919909737}
- {fileID: 255152392}
addOns: []
--- !u!1 &1166002035971444
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -979,7 +972,6 @@ GameObject:
- component: {fileID: 4034941481105394}
- component: {fileID: 1927650385544942642}
- component: {fileID: 1937006548859440174}
- component: {fileID: 1954678272987103162}
m_Layer: 0
m_Name: RL
m_TagString: Untagged
Expand Down Expand Up @@ -1046,19 +1038,6 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!114 &1954678272987103162
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1243993277687504}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b72eb77adaa94a242836ec46ffbe98be, type: 3}
m_Name:
m_EditorClassIdentifier:
entries: []
--- !u!1 &1311656790281508
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1583,7 +1562,6 @@ GameObject:
- component: {fileID: 4732569812067590}
- component: {fileID: 1931413126814977078}
- component: {fileID: 1938566618271409824}
- component: {fileID: 1954723963721948860}
m_Layer: 0
m_Name: FL
m_TagString: Untagged
Expand Down Expand Up @@ -1650,19 +1628,6 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!114 &1954723963721948860
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1576848716418974}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b72eb77adaa94a242836ec46ffbe98be, type: 3}
m_Name:
m_EditorClassIdentifier:
entries: []
--- !u!1 &1581806044544236
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2096,7 +2061,6 @@ GameObject:
- component: {fileID: 4739135267531380}
- component: {fileID: 1931387474880817522}
- component: {fileID: 1937690708180490964}
- component: {fileID: 1954795816283824388}
m_Layer: 0
m_Name: RR
m_TagString: Untagged
Expand Down Expand Up @@ -2163,19 +2127,6 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!114 &1954795816283824388
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1736395382457428}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b72eb77adaa94a242836ec46ffbe98be, type: 3}
m_Name:
m_EditorClassIdentifier:
entries: []
--- !u!1 &1747655489329494
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2766,7 +2717,6 @@ GameObject:
- component: {fileID: 4346771767283920}
- component: {fileID: 1928415736752769256}
- component: {fileID: 1938298222646736474}
- component: {fileID: 1955557788347080344}
m_Layer: 0
m_Name: FR
m_TagString: Untagged
Expand Down Expand Up @@ -2833,19 +2783,6 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!114 &1955557788347080344
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1940818199909830}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b72eb77adaa94a242836ec46ffbe98be, type: 3}
m_Name:
m_EditorClassIdentifier:
entries: []
--- !u!1 &1963444167204864
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2979,7 +2916,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
ackermann: {fileID: 1214198106228332029}
maxTorque: 1000
maxTorque: 500
value: 0
--- !u!1 &1214198106228332026
GameObject:
Expand Down Expand Up @@ -3117,9 +3054,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a28b5a52112c97342bb0ca5d468e15b7, type: 3}
m_Name:
m_EditorClassIdentifier:
idleRPM: 600
maxTorque: 500
value: 0
m_MaxReverseInput: -0.5
rpmReadonly: 0
ackermann: {fileID: 1214198106228332029}
--- !u!1 &1214198106691927562
GameObject:
Expand Down Expand Up @@ -3159,7 +3098,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1214198106691927562}
m_Enabled: 0
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3ea26387ab63fdc4088fabfe3a742a8e, type: 3}
m_Name:
Expand Down
43 changes: 0 additions & 43 deletions Assets/Tork/Samples/Scenes/Demo.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Assets/Tork/Samples/Scenes/Demo.cs.meta

This file was deleted.

0 comments on commit 97f4eba

Please sign in to comment.