new input system, wheel in Wheel class

This commit is contained in:
2023-06-14 14:35:32 +02:00
parent 94d5fb3892
commit 9299d95a13
31 changed files with 1250 additions and 306 deletions

View File

@@ -187,7 +187,7 @@ GameObject:
- component: {fileID: 2658126405065944351}
- component: {fileID: 3919563610228570404}
m_Layer: 0
m_Name: RightRear
m_Name: RearRight
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -587,6 +587,7 @@ WheelCollider:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5511142887409963698}
serializedVersion: 2
m_Center: {x: 0, y: 0, z: 0}
m_Radius: 0.66
m_SuspensionSpring:
@@ -609,7 +610,15 @@ WheelCollider:
m_AsymptoteSlip: 0.5
m_AsymptoteValue: 0.75
m_Stiffness: 1
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_Enabled: 1
m_ProvidesContacts: 0
--- !u!1 &6197753408674948659
GameObject:
m_ObjectHideFlags: 0
@@ -741,10 +750,21 @@ Rigidbody:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6635559819384152539}
serializedVersion: 2
serializedVersion: 4
m_Mass: 1000
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
@@ -758,9 +778,17 @@ BoxCollider:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6635559819384152539}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 2
serializedVersion: 3
m_Size: {x: 3.8350902, y: 2.5088034, z: 9.797295}
m_Center: {x: -0.054754972, y: 0.7544017, z: -0.34678173}
--- !u!114 &7484181368601986816
@@ -775,16 +803,28 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d4961da06d90aa141a3f8753f8273d1b, type: 3}
m_Name:
m_EditorClassIdentifier:
frontRightWheelCollider: {fileID: 3709301375758161893}
frontLeftWheelCollider: {fileID: 7197399277290813424}
rearRightWheelCollider: {fileID: 6716099154789843407}
rearLeftWheelCollider: {fileID: 8756131927912224202}
frontRightWheel: {fileID: 8603147080505033577}
frontLeftWheel: {fileID: 5406544531487247495}
rearRightWheel: {fileID: 9144114124687175875}
rearLeftWheel: {fileID: 3254342925887961269}
acceleration: 500
breakingForce: 300
frontRightWheel:
collider: {fileID: 3709301375758161893}
wheel: {fileID: 8603147080505033577}
wheelSize: 16
frontLeftWheel:
collider: {fileID: 7197399277290813424}
wheel: {fileID: 5406544531487247495}
wheelSize: 16
rearRightWheel:
collider: {fileID: 6716099154789843407}
wheel: {fileID: 9144114124687175875}
wheelSize: 16
rearLeftWheel:
collider: {fileID: 8756131927912224202}
wheel: {fileID: 3254342925887961269}
wheelSize: 16
flRpmLabel: {fileID: 0}
frRpmLabel: {fileID: 0}
rlRpmLabel: {fileID: 0}
rrRpmLabel: {fileID: 0}
acceleration: 1000
breakingForce: 1000
maxTurnAngle: 45
--- !u!1 &7192189071031128551
GameObject:
@@ -825,6 +865,7 @@ WheelCollider:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7192189071031128551}
serializedVersion: 2
m_Center: {x: 0, y: 0, z: 0}
m_Radius: 0.66
m_SuspensionSpring:
@@ -847,7 +888,15 @@ WheelCollider:
m_AsymptoteSlip: 0.5
m_AsymptoteValue: 0.75
m_Stiffness: 1
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_Enabled: 1
m_ProvidesContacts: 0
--- !u!1 &8362515007327840337
GameObject:
m_ObjectHideFlags: 0
@@ -922,6 +971,7 @@ WheelCollider:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8372165502191654333}
serializedVersion: 2
m_Center: {x: 0, y: 0, z: 0}
m_Radius: 0.66
m_SuspensionSpring:
@@ -944,7 +994,15 @@ WheelCollider:
m_AsymptoteSlip: 0.5
m_AsymptoteValue: 0.75
m_Stiffness: 1
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_Enabled: 1
m_ProvidesContacts: 0
--- !u!1 &8701444454671332249
GameObject:
m_ObjectHideFlags: 0
@@ -984,6 +1042,7 @@ WheelCollider:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8701444454671332249}
serializedVersion: 2
m_Center: {x: 0, y: 0, z: 0}
m_Radius: 0.66
m_SuspensionSpring:
@@ -1006,7 +1065,15 @@ WheelCollider:
m_AsymptoteSlip: 0.5
m_AsymptoteValue: 0.75
m_Stiffness: 1
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_Enabled: 1
m_ProvidesContacts: 0
--- !u!1 &8716395517054482359
GameObject:
m_ObjectHideFlags: 0

View File

@@ -9,6 +9,8 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: Grey
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
@@ -18,6 +20,7 @@ Material:
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
@@ -123,4 +126,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
version: 7

View File

@@ -9,6 +9,8 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: Orange
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
@@ -18,6 +20,7 @@ Material:
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
@@ -123,4 +126,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
version: 7

View File

@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
version: 7
--- !u!21 &2100000
Material:
serializedVersion: 8
@@ -22,6 +22,8 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: Red
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
@@ -31,6 +33,7 @@ Material:
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

View File

@@ -9,6 +9,8 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: Window
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
@@ -18,6 +20,7 @@ Material:
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
@@ -123,4 +126,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
version: 7

View File

@@ -9,6 +9,8 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: black
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
@@ -18,6 +20,7 @@ Material:
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
@@ -123,4 +126,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
version: 7

View File

@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
version: 7
--- !u!21 &2100000
Material:
serializedVersion: 8
@@ -22,6 +22,8 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: tofu_shop
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
@@ -31,6 +33,7 @@ Material:
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

View File

@@ -9,6 +9,8 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: white
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
@@ -18,6 +20,7 @@ Material:
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
@@ -123,4 +126,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
version: 7

View File

@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
version: 7
--- !u!21 &2100000
Material:
serializedVersion: 8
@@ -22,6 +22,8 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: tire
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
@@ -31,6 +33,7 @@ Material:
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

8
Assets/Input.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fdef42b5728717d48a6256dc65ac1103
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

394
Assets/Input/InputMaster.cs Normal file
View File

@@ -0,0 +1,394 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
// version 1.6.1
// from Assets/Input/InputMaster.inputactions
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
public partial class @InputMaster: IInputActionCollection2, IDisposable
{
public InputActionAsset asset { get; }
public @InputMaster()
{
asset = InputActionAsset.FromJson(@"{
""name"": ""InputMaster"",
""maps"": [
{
""name"": ""Car"",
""id"": ""279efb2e-a9ae-40e7-af18-b556d8e58b59"",
""actions"": [
{
""name"": ""Movement"",
""type"": ""Button"",
""id"": ""30aae96b-847c-40a0-aff6-3f1951d55ca3"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Turn"",
""type"": ""Button"",
""id"": ""0be415b5-08e4-453d-9e28-fb9b7eff7e38"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Brake"",
""type"": ""Button"",
""id"": ""190563e6-0fc1-4263-9f0e-919667264461"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
{
""name"": ""Z"",
""id"": ""8c181f14-d941-40de-b32a-0d2bd55fa6f8"",
""path"": ""1DAxis"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Movement"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""negative"",
""id"": ""93df6b39-9305-4203-bd02-1528711041d5"",
""path"": ""<Gamepad>/leftTrigger"",
""interactions"": """",
""processors"": """",
""groups"": ""Gamepad"",
""action"": ""Movement"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""positive"",
""id"": ""74248671-ae82-4fb8-9b1e-7c716d7a918a"",
""path"": ""<Gamepad>/rightTrigger"",
""interactions"": """",
""processors"": """",
""groups"": ""Gamepad"",
""action"": ""Movement"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""Z"",
""id"": ""3f962054-2147-4969-a731-b2aed5c280d2"",
""path"": ""1DAxis"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Movement"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""negative"",
""id"": ""5806e9c3-6fff-4468-9777-fa799e5356cd"",
""path"": ""<Keyboard>/downArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Movement"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""positive"",
""id"": ""bd366aea-6bef-4aa2-8ec9-98e0564017a2"",
""path"": ""<Keyboard>/upArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Movement"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""X"",
""id"": ""449c5b18-ec83-4072-813e-bebae2c84785"",
""path"": ""1DAxis"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Turn"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""negative"",
""id"": ""dd9f85b5-dd05-49f4-a0be-22d4e0f1d9fc"",
""path"": ""<Gamepad>/leftStick/left"",
""interactions"": """",
""processors"": """",
""groups"": ""Gamepad"",
""action"": ""Turn"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""positive"",
""id"": ""aa7bd576-99ff-4b74-b023-f25395d6ad9e"",
""path"": ""<Gamepad>/leftStick/right"",
""interactions"": """",
""processors"": """",
""groups"": ""Gamepad"",
""action"": ""Turn"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""X"",
""id"": ""b0942bad-1a51-4bd7-9fce-a0d408272cc8"",
""path"": ""1DAxis"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Turn"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""negative"",
""id"": ""72cf4953-8c6b-4bce-8216-9b994421aef2"",
""path"": ""<Keyboard>/leftArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Turn"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""positive"",
""id"": ""5532b214-24f7-4e1e-aa5f-b9e20c7b0ae4"",
""path"": ""<Keyboard>/rightArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Turn"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": """",
""id"": ""5bd100b8-204f-41d9-8870-2df4129bb4c3"",
""path"": ""<Keyboard>/space"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Brake"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""1759b642-aa43-4fa3-a5d2-ab4356b087a6"",
""path"": ""<Gamepad>/buttonEast"",
""interactions"": """",
""processors"": """",
""groups"": ""Gamepad"",
""action"": ""Brake"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
],
""controlSchemes"": [
{
""name"": ""Gamepad"",
""bindingGroup"": ""Gamepad"",
""devices"": [
{
""devicePath"": ""<DualShockGamepad>"",
""isOptional"": false,
""isOR"": false
},
{
""devicePath"": ""<XInputController>"",
""isOptional"": false,
""isOR"": false
}
]
},
{
""name"": ""Keyboard"",
""bindingGroup"": ""Keyboard"",
""devices"": [
{
""devicePath"": ""<Keyboard>"",
""isOptional"": false,
""isOR"": false
}
]
}
]
}");
// Car
m_Car = asset.FindActionMap("Car", throwIfNotFound: true);
m_Car_Movement = m_Car.FindAction("Movement", throwIfNotFound: true);
m_Car_Turn = m_Car.FindAction("Turn", throwIfNotFound: true);
m_Car_Brake = m_Car.FindAction("Brake", throwIfNotFound: true);
}
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
public ReadOnlyArray<InputDevice>? devices
{
get => asset.devices;
set => asset.devices = value;
}
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
public IEnumerator<InputAction> GetEnumerator()
{
return asset.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Enable()
{
asset.Enable();
}
public void Disable()
{
asset.Disable();
}
public IEnumerable<InputBinding> bindings => asset.bindings;
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
{
return asset.FindAction(actionNameOrId, throwIfNotFound);
}
public int FindBinding(InputBinding bindingMask, out InputAction action)
{
return asset.FindBinding(bindingMask, out action);
}
// Car
private readonly InputActionMap m_Car;
private List<ICarActions> m_CarActionsCallbackInterfaces = new List<ICarActions>();
private readonly InputAction m_Car_Movement;
private readonly InputAction m_Car_Turn;
private readonly InputAction m_Car_Brake;
public struct CarActions
{
private @InputMaster m_Wrapper;
public CarActions(@InputMaster wrapper) { m_Wrapper = wrapper; }
public InputAction @Movement => m_Wrapper.m_Car_Movement;
public InputAction @Turn => m_Wrapper.m_Car_Turn;
public InputAction @Brake => m_Wrapper.m_Car_Brake;
public InputActionMap Get() { return m_Wrapper.m_Car; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(CarActions set) { return set.Get(); }
public void AddCallbacks(ICarActions instance)
{
if (instance == null || m_Wrapper.m_CarActionsCallbackInterfaces.Contains(instance)) return;
m_Wrapper.m_CarActionsCallbackInterfaces.Add(instance);
@Movement.started += instance.OnMovement;
@Movement.performed += instance.OnMovement;
@Movement.canceled += instance.OnMovement;
@Turn.started += instance.OnTurn;
@Turn.performed += instance.OnTurn;
@Turn.canceled += instance.OnTurn;
@Brake.started += instance.OnBrake;
@Brake.performed += instance.OnBrake;
@Brake.canceled += instance.OnBrake;
}
private void UnregisterCallbacks(ICarActions instance)
{
@Movement.started -= instance.OnMovement;
@Movement.performed -= instance.OnMovement;
@Movement.canceled -= instance.OnMovement;
@Turn.started -= instance.OnTurn;
@Turn.performed -= instance.OnTurn;
@Turn.canceled -= instance.OnTurn;
@Brake.started -= instance.OnBrake;
@Brake.performed -= instance.OnBrake;
@Brake.canceled -= instance.OnBrake;
}
public void RemoveCallbacks(ICarActions instance)
{
if (m_Wrapper.m_CarActionsCallbackInterfaces.Remove(instance))
UnregisterCallbacks(instance);
}
public void SetCallbacks(ICarActions instance)
{
foreach (var item in m_Wrapper.m_CarActionsCallbackInterfaces)
UnregisterCallbacks(item);
m_Wrapper.m_CarActionsCallbackInterfaces.Clear();
AddCallbacks(instance);
}
}
public CarActions @Car => new CarActions(this);
private int m_GamepadSchemeIndex = -1;
public InputControlScheme GamepadScheme
{
get
{
if (m_GamepadSchemeIndex == -1) m_GamepadSchemeIndex = asset.FindControlSchemeIndex("Gamepad");
return asset.controlSchemes[m_GamepadSchemeIndex];
}
}
private int m_KeyboardSchemeIndex = -1;
public InputControlScheme KeyboardScheme
{
get
{
if (m_KeyboardSchemeIndex == -1) m_KeyboardSchemeIndex = asset.FindControlSchemeIndex("Keyboard");
return asset.controlSchemes[m_KeyboardSchemeIndex];
}
}
public interface ICarActions
{
void OnMovement(InputAction.CallbackContext context);
void OnTurn(InputAction.CallbackContext context);
void OnBrake(InputAction.CallbackContext context);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d36508772a7fec945878014896f4e770
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,223 @@
{
"name": "InputMaster",
"maps": [
{
"name": "Car",
"id": "279efb2e-a9ae-40e7-af18-b556d8e58b59",
"actions": [
{
"name": "Movement",
"type": "Button",
"id": "30aae96b-847c-40a0-aff6-3f1951d55ca3",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Turn",
"type": "Button",
"id": "0be415b5-08e4-453d-9e28-fb9b7eff7e38",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Brake",
"type": "Button",
"id": "190563e6-0fc1-4263-9f0e-919667264461",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
{
"name": "Z",
"id": "8c181f14-d941-40de-b32a-0d2bd55fa6f8",
"path": "1DAxis",
"interactions": "",
"processors": "",
"groups": "",
"action": "Movement",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "negative",
"id": "93df6b39-9305-4203-bd02-1528711041d5",
"path": "<Gamepad>/leftTrigger",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Movement",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "positive",
"id": "74248671-ae82-4fb8-9b1e-7c716d7a918a",
"path": "<Gamepad>/rightTrigger",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Movement",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "Z",
"id": "3f962054-2147-4969-a731-b2aed5c280d2",
"path": "1DAxis",
"interactions": "",
"processors": "",
"groups": "",
"action": "Movement",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "negative",
"id": "5806e9c3-6fff-4468-9777-fa799e5356cd",
"path": "<Keyboard>/downArrow",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Movement",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "positive",
"id": "bd366aea-6bef-4aa2-8ec9-98e0564017a2",
"path": "<Keyboard>/upArrow",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Movement",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "X",
"id": "449c5b18-ec83-4072-813e-bebae2c84785",
"path": "1DAxis",
"interactions": "",
"processors": "",
"groups": "",
"action": "Turn",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "negative",
"id": "dd9f85b5-dd05-49f4-a0be-22d4e0f1d9fc",
"path": "<Gamepad>/leftStick/left",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Turn",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "positive",
"id": "aa7bd576-99ff-4b74-b023-f25395d6ad9e",
"path": "<Gamepad>/leftStick/right",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Turn",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "X",
"id": "b0942bad-1a51-4bd7-9fce-a0d408272cc8",
"path": "1DAxis",
"interactions": "",
"processors": "",
"groups": "",
"action": "Turn",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "negative",
"id": "72cf4953-8c6b-4bce-8216-9b994421aef2",
"path": "<Keyboard>/leftArrow",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Turn",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "positive",
"id": "5532b214-24f7-4e1e-aa5f-b9e20c7b0ae4",
"path": "<Keyboard>/rightArrow",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Turn",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "5bd100b8-204f-41d9-8870-2df4129bb4c3",
"path": "<Keyboard>/space",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Brake",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "1759b642-aa43-4fa3-a5d2-ab4356b087a6",
"path": "<Gamepad>/buttonEast",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Brake",
"isComposite": false,
"isPartOfComposite": false
}
]
}
],
"controlSchemes": [
{
"name": "Gamepad",
"bindingGroup": "Gamepad",
"devices": [
{
"devicePath": "<DualShockGamepad>",
"isOptional": false,
"isOR": false
},
{
"devicePath": "<XInputController>",
"isOptional": false,
"isOR": false
}
]
},
{
"name": "Keyboard",
"bindingGroup": "Keyboard",
"devices": [
{
"devicePath": "<Keyboard>",
"isOptional": false,
"isOR": false
}
]
}
]
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: e37caa3d2c5ccb14aadbdc76b282b649
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
generateWrapperCode: 1
wrapperCodePath:
wrapperClassName:
wrapperCodeNamespace:

View File

@@ -104,7 +104,7 @@ NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
serializedVersion: 3
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
@@ -117,7 +117,7 @@ NavMeshSettings:
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
@@ -445,6 +445,7 @@ GameObject:
- component: {fileID: 330585547}
- component: {fileID: 330585548}
- component: {fileID: 330585549}
- component: {fileID: 330585550}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
@@ -474,9 +475,17 @@ Camera:
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_Iso: 200
m_ShutterSpeed: 0.005
m_Aperture: 16
m_FocusDistance: 10
m_FocalLength: 50
m_BladeCount: 5
m_Curvature: {x: 2, y: 11}
m_BarrelClipping: 0.25
m_Anamorphism: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
@@ -510,7 +519,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
m_LocalRotation: {x: 0.18910755, y: 0, z: 0, w: 0.9819564}
m_LocalRotation: {x: 0.18910752, y: 0, z: 0, w: 0.9819564}
m_LocalPosition: {x: -1.3821344, y: 9.9834175, z: -20.275475}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@@ -548,9 +557,20 @@ MonoBehaviour:
m_Dithering: 0
m_ClearDepth: 1
m_AllowXRRendering: 1
m_AllowHDROutput: 1
m_UseScreenCoordOverride: 0
m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0}
m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0}
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2
m_TaaSettings:
quality: 3
frameInfluence: 0.1
jitterScale: 1
mipBias: 0
varianceClampScale: 0.9
contrastAdaptiveSharpening: 0
--- !u!114 &330585548
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -597,6 +617,22 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: bcd90519abd2eaa47ab4e721bdbe12c8, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &330585550
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6f97ad1a9bdec0d4eb723002348f6a94, type: 3}
m_Name:
m_EditorClassIdentifier:
flRpmLabel: {fileID: 1249082957}
frRpmLabel: {fileID: 1962769954}
rlRpmLabel: {fileID: 279508388}
rrRpmLabel: {fileID: 212741547}
--- !u!1 &410087039
GameObject:
m_ObjectHideFlags: 0
@@ -690,7 +726,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!114 &410087042
MonoBehaviour:
@@ -704,14 +740,17 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Version: 1
m_Version: 3
m_UsePipelineSettings: 1
m_AdditionalLightsShadowResolutionTier: 2
m_LightLayerMask: 1
m_RenderingLayers: 1
m_CustomShadowLayers: 0
m_ShadowLayerMask: 1
m_ShadowRenderingLayers: 1
m_LightCookieSize: {x: 1, y: 1}
m_LightCookieOffset: {x: 0, y: 0}
m_SoftShadowQuality: 1
--- !u!1 &590315768
GameObject:
m_ObjectHideFlags: 0
@@ -1145,8 +1184,8 @@ MonoBehaviour:
m_StreamingVersion: 20170927
m_Priority: 10
m_StandbyUpdate: 2
m_LookAt: {fileID: 1610757029}
m_Follow: {fileID: 1610757029}
m_LookAt: {fileID: 0}
m_Follow: {fileID: 0}
m_CommonLens: 1
m_Lens:
FieldOfView: 60
@@ -1157,6 +1196,7 @@ MonoBehaviour:
ModeOverride: 0
LensShift: {x: 0, y: 0}
GateFit: 2
FocusDistance: 10
m_SensorSize: {x: 1, y: 1}
m_Transitions:
m_BlendHint: 0
@@ -1349,7 +1389,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &905580687
GameObject:
@@ -1478,6 +1518,79 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1017951274
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalPosition.x
value: 2.6789722
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalPosition.y
value: 1.4428409
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalPosition.z
value: -1.0264323
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6635559819384152539, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_Name
value: 86
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 8a97cc7d459762945ab8e9f6ae4bac33, type: 3}
--- !u!1 &1063055264
GameObject:
m_ObjectHideFlags: 3
@@ -1531,6 +1644,7 @@ MonoBehaviour:
ModeOverride: 0
LensShift: {x: 0, y: 0}
GateFit: 2
FocusDistance: 10
m_SensorSize: {x: 1, y: 1}
m_Transitions:
m_BlendHint: 0
@@ -1782,6 +1896,7 @@ MonoBehaviour:
ModeOverride: 0
LensShift: {x: 0, y: 0}
GateFit: 2
FocusDistance: 10
m_SensorSize: {x: 1, y: 1}
m_Transitions:
m_BlendHint: 0
@@ -1995,6 +2110,7 @@ MonoBehaviour:
ModeOverride: 0
LensShift: {x: 0, y: 0}
GateFit: 2
FocusDistance: 10
m_SensorSize: {x: 1, y: 1}
m_Transitions:
m_BlendHint: 0
@@ -2047,9 +2163,17 @@ BoxCollider:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1509071307}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 2
serializedVersion: 3
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &1509071309
@@ -2115,7 +2239,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1594060431
GameObject:
@@ -2244,12 +2368,6 @@ MonoBehaviour:
m_BiasX: 0
m_BiasY: 0
m_CenterOnActivate: 1
--- !u!4 &1610757029 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
m_PrefabInstance: {fileID: 4166904890576558728}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1735399694
GameObject:
m_ObjectHideFlags: 0
@@ -2664,7 +2782,9 @@ Canvas:
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 25
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
@@ -2730,112 +2850,3 @@ RectTransform:
m_AnchoredPosition: {x: -366.1421, y: 417.00006}
m_SizeDelta: {x: 244.1437, y: 73.9168}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1001 &4166904890576558728
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalPosition.x
value: -1.3821344
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalPosition.y
value: 2.67
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalPosition.z
value: 0.29676378
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6295450445658667873, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6635559819384152539, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_Name
value: 86
objectReference: {fileID: 0}
- target: {fileID: 7484181368601986816, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: flRpmLabel
value:
objectReference: {fileID: 1249082957}
- target: {fileID: 7484181368601986816, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: frRpmLabel
value:
objectReference: {fileID: 1962769954}
- target: {fileID: 7484181368601986816, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: rlRpmLabel
value:
objectReference: {fileID: 279508388}
- target: {fileID: 7484181368601986816, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: rrRpmLabel
value:
objectReference: {fileID: 212741547}
- target: {fileID: 7484181368601986816, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: acceleration
value: 1000
objectReference: {fileID: 0}
- target: {fileID: 7484181368601986816, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: maxTurnAngle
value: 45
objectReference: {fileID: 0}
- target: {fileID: 7484181368601986816, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: breakingForce
value: 1000
objectReference: {fileID: 0}
- target: {fileID: 8171421669866221158, guid: 8a97cc7d459762945ab8e9f6ae4bac33,
type: 3}
propertyPath: m_Mass
value: 1000
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 8a97cc7d459762945ab8e9f6ae4bac33, type: 3}

View File

@@ -1,8 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class DebugInfo : MonoBehaviour
{
{
[SerializeField] private TMP_Text flRpmLabel;
[SerializeField] private TMP_Text frRpmLabel;
[SerializeField] private TMP_Text rlRpmLabel;
[SerializeField] private TMP_Text rrRpmLabel;
public void setRpmLabels(float flRpm, float frRpm, float rlRpm, float rrRpm){
flRpmLabel.text = flRpm.ToString();
frRpmLabel.text = frRpm.ToString();
rlRpmLabel.text = rlRpm.ToString();
rrRpmLabel.text = rrRpm.ToString();
}
}

35
Assets/Scripts/Wheel.cs Normal file
View File

@@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Wheel
{
[SerializeField] private WheelCollider collider;
[SerializeField] private Transform wheel;
[SerializeField] private float wheelSize = 15; //default size change to what the actual size is
public float GetWheelRPM(){ return collider.rpm; } //return the wheels current rpm
public void ApplySteerAngle(float steerAngle){ //apply steer angle to wheel to rotate
collider.steerAngle = steerAngle;
}
public void ApplyBrakeForce(float brakeForce){ //apply brake force to the wheel
collider.brakeTorque = brakeForce;
}
public void ApplyAcceleration(float acceleration){ //apply acceleration value to the wheel
collider.motorTorque = acceleration;
}
public void UpdateWheel(){ //rotates the wheel when the car is moving
Vector3 position;
Quaternion rotation;
collider.GetWorldPose(out position, out rotation);
wheel.position = position;
wheel.rotation = rotation;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a2f70e41819e6cc49ac12be4ce0c0612
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,25 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.InputSystem;
public class WheelController : MonoBehaviour
{
[SerializeField] private WheelCollider frontRightWheelCollider;
[SerializeField] private WheelCollider frontLeftWheelCollider;
[SerializeField] private WheelCollider rearRightWheelCollider;
[SerializeField] private WheelCollider rearLeftWheelCollider;
//wheel meshes
[SerializeField] private Transform frontRightWheel;
[SerializeField] private Transform frontLeftWheel;
[SerializeField] private Transform rearRightWheel;
[SerializeField] private Transform rearLeftWheel;
[SerializeField] private TMP_Text flRpmLabel;
[SerializeField] private TMP_Text frRpmLabel;
[SerializeField] private TMP_Text rlRpmLabel;
[SerializeField] private TMP_Text rrRpmLabel;
[SerializeField] private Wheel frontRightWheel;
[SerializeField] private Wheel frontLeftWheel;
[SerializeField] private Wheel rearRightWheel;
[SerializeField] private Wheel rearLeftWheel;
public float acceleration = 500f;
public float breakingForce = 300f;
@@ -29,71 +18,56 @@ public class WheelController : MonoBehaviour
private float currentBrakeForce = 0f;
private float currentTurnAngle = 0f;
private void Update() {
flRpmLabel.text = getWheelRPM(frontLeftWheelCollider).ToString();
frRpmLabel.text = getWheelRPM(frontRightWheelCollider).ToString();
rlRpmLabel.text = getWheelRPM(rearLeftWheelCollider).ToString();
rrRpmLabel.text = getWheelRPM(rearRightWheelCollider).ToString();
private DebugInfo debugInfo;
//inputs
private InputMaster controls;
private InputAction movement;
private InputAction turn;
private InputAction brake;
private void Awake() {
debugInfo = FindObjectOfType<DebugInfo>();
controls = new InputMaster();
}
private float getWheelRPM(WheelCollider wheel){
return wheel.rpm;
private void Update() {
debugInfo.setRpmLabels(frontLeftWheel.GetWheelRPM(), frontRightWheel.GetWheelRPM(), rearLeftWheel.GetWheelRPM(), rearRightWheel.GetWheelRPM());
}
private void FixedUpdate() {
//TODO: Update input info to new input system
//forward reverse input
currentAcceleration = acceleration * Input.GetAxis("Vertical");
//currentAcceleration = acceleration * Input.GetAxis("Vertical");
//breaking input
if(Input.GetKey(KeyCode.Space)){
/*if(Input.GetKey(KeyCode.Space)){
currentBrakeForce = breakingForce;
}else{
currentBrakeForce = 0f;
}
}*/
//apply acceleration to front wheels| (this determines which wheel drive is the car (fwd, awd, rwd))
ApplyAccelerationToWheel(rearRightWheelCollider, currentAcceleration);
ApplyAccelerationToWheel(rearLeftWheelCollider, currentAcceleration);
rearRightWheel.ApplyAcceleration(currentAcceleration);
rearLeftWheel.ApplyAcceleration(currentAcceleration);
//break applies to all four wheels
ApplyBrakeToWheel(frontLeftWheelCollider, currentBrakeForce);
ApplyBrakeToWheel(frontRightWheelCollider, currentBrakeForce);
ApplyBrakeToWheel(rearLeftWheelCollider, currentBrakeForce);
ApplyBrakeToWheel(rearRightWheelCollider, currentBrakeForce);
frontLeftWheel.ApplyBrakeForce(currentBrakeForce);
frontRightWheel.ApplyBrakeForce(currentBrakeForce);
rearLeftWheel.ApplyBrakeForce(currentBrakeForce);
rearRightWheel.ApplyBrakeForce(currentBrakeForce);
//steering
currentTurnAngle = maxTurnAngle * Input.GetAxis("Horizontal"); //getting steering input
ApplyStreering(currentTurnAngle);
//currentTurnAngle = maxTurnAngle * Input.GetAxis("Horizontal"); //getting steering input
frontLeftWheel.ApplySteerAngle(currentTurnAngle);
frontRightWheel.ApplySteerAngle(currentTurnAngle);
//update wheel meshes
UpdateWheel(frontLeftWheelCollider, frontLeftWheel);
UpdateWheel(frontRightWheelCollider, frontRightWheel);
UpdateWheel(rearLeftWheelCollider, rearLeftWheel);
UpdateWheel(rearRightWheelCollider, rearRightWheel);
}
private void ApplyStreering(float streeringAngle){
frontLeftWheelCollider.steerAngle = streeringAngle;
frontRightWheelCollider.steerAngle = streeringAngle;
}
private void ApplyBrakeToWheel(WheelCollider wheel, float breakForce){
wheel.brakeTorque = breakForce;
}
private void ApplyAccelerationToWheel(WheelCollider wheel, float acceleration){
wheel.motorTorque = acceleration;
}
private void UpdateWheel(WheelCollider collider, Transform wheel){
//get collider state
Vector3 position;
Quaternion rotation;
collider.GetWorldPose(out position, out rotation); //puts it into position and rotation
//set wheel state
wheel.position = position;
wheel.rotation = rotation;
frontLeftWheel.UpdateWheel();
frontRightWheel.UpdateWheel();
rearLeftWheel.UpdateWheel();
rearRightWheel.UpdateWheel();
}
}

View File

@@ -12,8 +12,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
m_Name: URP-Balanced
m_EditorClassIdentifier:
k_AssetVersion: 9
k_AssetPreviousVersion: 9
k_AssetVersion: 11
k_AssetPreviousVersion: 11
m_RendererType: 1
m_RendererData: {fileID: 0}
m_RendererDataList:
@@ -23,13 +23,16 @@ MonoBehaviour:
m_RequireOpaqueTexture: 0
m_OpaqueDownsampling: 1
m_SupportsTerrainHoles: 1
m_StoreActionsOptimization: 0
m_SupportsHDR: 1
m_HDRColorBufferPrecision: 0
m_MSAA: 1
m_RenderScale: 1
m_UpscalingFilter: 0
m_FsrOverrideSharpness: 0
m_FsrSharpness: 0.92
m_EnableLODCrossFade: 1
m_LODCrossFadeDitheringType: 1
m_ShEvalMode: 0
m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 1
m_MainLightShadowmapResolution: 1024
@@ -50,16 +53,21 @@ MonoBehaviour:
m_CascadeBorder: 0.1
m_ShadowDepthBias: 1
m_ShadowNormalBias: 1
m_AnyShadowsSupported: 1
m_SoftShadowsSupported: 1
m_ConservativeEnclosingSphere: 0
m_NumIterationsEnclosingSphere: 64
m_SoftShadowQuality: 2
m_AdditionalLightsCookieResolution: 512
m_AdditionalLightsCookieFormat: 1
m_UseSRPBatcher: 1
m_SupportsDynamicBatching: 0
m_MixedLightingSupported: 1
m_SupportsLightCookies: 1
m_SupportsLightLayers: 0
m_DebugLevel: 0
m_StoreActionsOptimization: 0
m_EnableRenderGraph: 0
m_UseAdaptivePerformance: 1
m_ColorGradingMode: 0
m_ColorGradingLutSize: 32
@@ -69,6 +77,33 @@ MonoBehaviour:
m_LocalShadowsAtlasResolution: 256
m_MaxPixelLights: 0
m_ShadowAtlasResolution: 256
m_ShaderVariantLogLevel: 0
m_VolumeFrameworkUpdateMode: 0
m_Textures:
blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}
m_PrefilteringModeMainLightShadows: 1
m_PrefilteringModeAdditionalLight: 4
m_PrefilteringModeAdditionalLightShadows: 1
m_PrefilterXRKeywords: 0
m_PrefilteringModeForwardPlus: 1
m_PrefilteringModeDeferredRendering: 1
m_PrefilteringModeScreenSpaceOcclusion: 1
m_PrefilterDebugKeywords: 0
m_PrefilterWriteRenderingLayers: 0
m_PrefilterHDROutput: 0
m_PrefilterSSAODepthNormals: 0
m_PrefilterSSAOSourceDepthLow: 0
m_PrefilterSSAOSourceDepthMedium: 0
m_PrefilterSSAOSourceDepthHigh: 0
m_PrefilterSSAOInterleaved: 0
m_PrefilterSSAOBlueNoise: 0
m_PrefilterSSAOSampleCountLow: 0
m_PrefilterSSAOSampleCountMedium: 0
m_PrefilterSSAOSampleCountHigh: 0
m_PrefilterDBufferMRT1: 0
m_PrefilterDBufferMRT2: 0
m_PrefilterDBufferMRT3: 0
m_PrefilterScreenCoord: 0
m_PrefilterNativeRenderPass: 0
m_ShaderVariantLogLevel: 0
m_ShadowCascades: 0

View File

@@ -13,8 +13,8 @@ MonoBehaviour:
m_Name: SSAO
m_EditorClassIdentifier:
m_Active: 1
m_Shader: {fileID: 4800000, guid: 0849e84e3d62649e8882e9d6f056a017, type: 3}
m_Settings:
AOMethod: 1
Downsample: 0
AfterOpaque: 0
Source: 1
@@ -22,7 +22,19 @@ MonoBehaviour:
Intensity: 0.5
DirectLightingStrength: 0.25
Radius: 0.25
SampleCount: 12
Samples: 0
BlurQuality: 0
Falloff: 100
SampleCount: -1
m_BlueNoise256Textures:
- {fileID: 2800000, guid: 36f118343fc974119bee3d09e2111500, type: 3}
- {fileID: 2800000, guid: 4b7b083e6b6734e8bb2838b0b50a0bc8, type: 3}
- {fileID: 2800000, guid: c06cc21c692f94f5fb5206247191eeee, type: 3}
- {fileID: 2800000, guid: cb76dd40fa7654f9587f6a344f125c9a, type: 3}
- {fileID: 2800000, guid: e32226222ff144b24bf3a5a451de54bc, type: 3}
- {fileID: 2800000, guid: 3302065f671a8450b82c9ddf07426f3a, type: 3}
- {fileID: 2800000, guid: 56a77a3e8d64f47b6afe9e3c95cb57d5, type: 3}
m_Shader: {fileID: 4800000, guid: 0849e84e3d62649e8882e9d6f056a017, type: 3}
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -38,11 +50,13 @@ MonoBehaviour:
debugShaders:
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7,
type: 3}
hdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3}
m_RendererFeatures:
- {fileID: -1878332245247344467}
m_RendererFeatureMap: adc0de57c6d2eee5
m_UseNativeRenderPass: 0
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2}
shaders:
blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3}
copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
@@ -50,15 +64,17 @@ MonoBehaviour:
samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
fallbackLoadingPS: {fileID: 4800000, guid: 7f888aff2ac86494babad1c2c5daeee2, type: 3}
materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3}
coreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3}
coreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b,
type: 3}
blitHDROverlay: {fileID: 4800000, guid: a89bee29cffa951418fc1e2da94d1959, type: 3}
cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf,
type: 3}
objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486,
type: 3}
m_AssetVersion: 1
m_AssetVersion: 2
m_OpaqueLayerMask:
serializedVersion: 2
m_Bits: 4294967295
@@ -75,7 +91,6 @@ MonoBehaviour:
m_ShadowTransparentReceive: 1
m_RenderingMode: 0
m_DepthPrimingMode: 1
m_CopyDepthMode: 0
m_AccurateGbufferNormals: 0
m_ClusteredRendering: 0
m_TileSize: 32
m_IntermediateTextureMode: 0

View File

@@ -12,8 +12,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
m_Name: URP-HighFidelity
m_EditorClassIdentifier:
k_AssetVersion: 9
k_AssetPreviousVersion: 9
k_AssetVersion: 11
k_AssetPreviousVersion: 11
m_RendererType: 1
m_RendererData: {fileID: 0}
m_RendererDataList:
@@ -23,13 +23,16 @@ MonoBehaviour:
m_RequireOpaqueTexture: 0
m_OpaqueDownsampling: 1
m_SupportsTerrainHoles: 1
m_StoreActionsOptimization: 0
m_SupportsHDR: 1
m_HDRColorBufferPrecision: 0
m_MSAA: 8
m_RenderScale: 1
m_UpscalingFilter: 0
m_FsrOverrideSharpness: 0
m_FsrSharpness: 0.92
m_EnableLODCrossFade: 1
m_LODCrossFadeDitheringType: 1
m_ShEvalMode: 0
m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 1
m_MainLightShadowmapResolution: 4096
@@ -54,13 +57,17 @@ MonoBehaviour:
m_SoftShadowsSupported: 1
m_ConservativeEnclosingSphere: 0
m_NumIterationsEnclosingSphere: 64
m_SoftShadowQuality: 2
m_AdditionalLightsCookieResolution: 4096
m_AdditionalLightsCookieFormat: 4
m_UseSRPBatcher: 1
m_SupportsDynamicBatching: 0
m_MixedLightingSupported: 1
m_SupportsLightCookies: 1
m_SupportsLightLayers: 0
m_DebugLevel: 0
m_StoreActionsOptimization: 0
m_EnableRenderGraph: 0
m_UseAdaptivePerformance: 1
m_ColorGradingMode: 0
m_ColorGradingLutSize: 32
@@ -70,6 +77,33 @@ MonoBehaviour:
m_LocalShadowsAtlasResolution: 256
m_MaxPixelLights: 0
m_ShadowAtlasResolution: 256
m_ShaderVariantLogLevel: 0
m_VolumeFrameworkUpdateMode: 0
m_Textures:
blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}
m_PrefilteringModeMainLightShadows: 1
m_PrefilteringModeAdditionalLight: 4
m_PrefilteringModeAdditionalLightShadows: 1
m_PrefilterXRKeywords: 0
m_PrefilteringModeForwardPlus: 1
m_PrefilteringModeDeferredRendering: 1
m_PrefilteringModeScreenSpaceOcclusion: 1
m_PrefilterDebugKeywords: 0
m_PrefilterWriteRenderingLayers: 0
m_PrefilterHDROutput: 0
m_PrefilterSSAODepthNormals: 0
m_PrefilterSSAOSourceDepthLow: 0
m_PrefilterSSAOSourceDepthMedium: 0
m_PrefilterSSAOSourceDepthHigh: 0
m_PrefilterSSAOInterleaved: 0
m_PrefilterSSAOBlueNoise: 0
m_PrefilterSSAOSampleCountLow: 0
m_PrefilterSSAOSampleCountMedium: 0
m_PrefilterSSAOSampleCountHigh: 0
m_PrefilterDBufferMRT1: 0
m_PrefilterDBufferMRT2: 0
m_PrefilterDBufferMRT3: 0
m_PrefilterScreenCoord: 0
m_PrefilterNativeRenderPass: 0
m_ShaderVariantLogLevel: 0
m_ShadowCascades: 1

View File

@@ -12,8 +12,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
m_Name: URP-Performant
m_EditorClassIdentifier:
k_AssetVersion: 9
k_AssetPreviousVersion: 9
k_AssetVersion: 11
k_AssetPreviousVersion: 11
m_RendererType: 1
m_RendererData: {fileID: 0}
m_RendererDataList:
@@ -23,10 +23,16 @@ MonoBehaviour:
m_RequireOpaqueTexture: 0
m_OpaqueDownsampling: 1
m_SupportsTerrainHoles: 1
m_StoreActionsOptimization: 0
m_SupportsHDR: 0
m_HDRColorBufferPrecision: 0
m_MSAA: 1
m_RenderScale: 1
m_UpscalingFilter: 0
m_FsrOverrideSharpness: 0
m_FsrSharpness: 0.92
m_EnableLODCrossFade: 1
m_LODCrossFadeDitheringType: 1
m_ShEvalMode: 0
m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 0
m_MainLightShadowmapResolution: 1024
@@ -47,14 +53,21 @@ MonoBehaviour:
m_CascadeBorder: 0.1
m_ShadowDepthBias: 1
m_ShadowNormalBias: 1
m_AnyShadowsSupported: 1
m_SoftShadowsSupported: 0
m_ConservativeEnclosingSphere: 0
m_NumIterationsEnclosingSphere: 64
m_SoftShadowQuality: 2
m_AdditionalLightsCookieResolution: 2048
m_AdditionalLightsCookieFormat: 3
m_UseSRPBatcher: 1
m_SupportsDynamicBatching: 0
m_MixedLightingSupported: 1
m_SupportsLightCookies: 1
m_SupportsLightLayers: 0
m_DebugLevel: 0
m_StoreActionsOptimization: 0
m_EnableRenderGraph: 0
m_UseAdaptivePerformance: 1
m_ColorGradingMode: 0
m_ColorGradingLutSize: 16
@@ -64,6 +77,33 @@ MonoBehaviour:
m_LocalShadowsAtlasResolution: 256
m_MaxPixelLights: 0
m_ShadowAtlasResolution: 256
m_ShaderVariantLogLevel: 0
m_VolumeFrameworkUpdateMode: 0
m_Textures:
blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}
m_PrefilteringModeMainLightShadows: 1
m_PrefilteringModeAdditionalLight: 4
m_PrefilteringModeAdditionalLightShadows: 1
m_PrefilterXRKeywords: 0
m_PrefilteringModeForwardPlus: 1
m_PrefilteringModeDeferredRendering: 1
m_PrefilteringModeScreenSpaceOcclusion: 1
m_PrefilterDebugKeywords: 0
m_PrefilterWriteRenderingLayers: 0
m_PrefilterHDROutput: 0
m_PrefilterSSAODepthNormals: 0
m_PrefilterSSAOSourceDepthLow: 0
m_PrefilterSSAOSourceDepthMedium: 0
m_PrefilterSSAOSourceDepthHigh: 0
m_PrefilterSSAOInterleaved: 0
m_PrefilterSSAOBlueNoise: 0
m_PrefilterSSAOSampleCountLow: 0
m_PrefilterSSAOSampleCountMedium: 0
m_PrefilterSSAOSampleCountHigh: 0
m_PrefilterDBufferMRT1: 0
m_PrefilterDBufferMRT2: 0
m_PrefilterDBufferMRT3: 0
m_PrefilterScreenCoord: 0
m_PrefilterNativeRenderPass: 0
m_ShaderVariantLogLevel: 0
m_ShadowCascades: 0

View File

@@ -12,7 +12,17 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2ec995e51a6e251468d2a3fd8a686257, type: 3}
m_Name: UniversalRenderPipelineGlobalSettings
m_EditorClassIdentifier:
k_AssetVersion: 2
k_AssetVersion: 3
m_RenderingLayerNames:
- Light Layer default
- Light Layer 1
- Light Layer 2
- Light Layer 3
- Light Layer 4
- Light Layer 5
- Light Layer 6
- Light Layer 7
m_ValidRenderingLayers: 255
lightLayerName0: Light Layer default
lightLayerName1: Light Layer 1
lightLayerName2: Light Layer 2
@@ -24,4 +34,8 @@ MonoBehaviour:
m_StripDebugVariants: 1
m_StripUnusedPostProcessingVariants: 1
m_StripUnusedVariants: 1
m_StripUnusedLODCrossFadeVariants: 1
m_StripScreenCoordOverrideVariants: 1
supportRuntimeDebugDisplay: 0
m_ShaderVariantLogLevel: 0
m_ExportShaderVariants: 1