Compare commits
2 Commits
54ae118eeb
...
31577e35ab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31577e35ab | ||
|
|
adf2969156 |
8
Assets/Car.meta
Normal file
8
Assets/Car.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a34845792b8aeab4e8d53b7827bb0e5d
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Car/Car Body.png
Normal file
BIN
Assets/Car/Car Body.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
130
Assets/Car/Car Body.png.meta
Normal file
130
Assets/Car/Car Body.png.meta
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0601a27fa7aa1744287b8b9ea1308280
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 13
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
flipGreenChannel: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
|
ignoreMipmapLimit: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: 1
|
||||||
|
aniso: 1
|
||||||
|
mipBias: 0
|
||||||
|
wrapU: 0
|
||||||
|
wrapV: 0
|
||||||
|
wrapW: 0
|
||||||
|
nPOTScale: 1
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 0
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 0
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 0
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
|
applyGammaDecoding: 0
|
||||||
|
swizzle: 50462976
|
||||||
|
cookieLightType: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: WebGL
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
customData:
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID:
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
spriteCustomMetadata:
|
||||||
|
entries: []
|
||||||
|
nameFileIdTable: {}
|
||||||
|
mipmapLimitGroupName:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Car/Scripts.meta
Normal file
8
Assets/Car/Scripts.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 098eddcc00087d94cacab8097c3112a2
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Car/Scripts/Car.meta
Normal file
8
Assets/Car/Scripts/Car.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bfdc5a5538675f14687a93215dc32d6d
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
93
Assets/Car/Scripts/Car/CarControl.cs
Normal file
93
Assets/Car/Scripts/Car/CarControl.cs
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class CarControl : MonoBehaviour
|
||||||
|
{
|
||||||
|
[Header("Car Properties")]
|
||||||
|
public float motorTorque = 2000f;
|
||||||
|
public float brakeTorque = 2000f;
|
||||||
|
public float maxSpeed = 20f;
|
||||||
|
public float steeringRange = 30f;
|
||||||
|
public float steeringRangeAtMaxSpeed = 10f;
|
||||||
|
public float centreOfGravityOffset = -1f;
|
||||||
|
|
||||||
|
private WheelControl[] wheels;
|
||||||
|
private Rigidbody rigidBody;
|
||||||
|
|
||||||
|
private CarInputActions carControls; // Reference to the new input system
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
carControls = new CarInputActions(); // Initialize Input Actions
|
||||||
|
}
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
carControls.Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDisable()
|
||||||
|
{
|
||||||
|
carControls.Disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
rigidBody = GetComponent<Rigidbody>();
|
||||||
|
|
||||||
|
// Adjust center of mass to improve stability and prevent rolling
|
||||||
|
Vector3 centerOfMass = rigidBody.centerOfMass;
|
||||||
|
centerOfMass.y += centreOfGravityOffset;
|
||||||
|
rigidBody.centerOfMass = centerOfMass;
|
||||||
|
|
||||||
|
// Get all wheel components attached to the car
|
||||||
|
wheels = GetComponentsInChildren<WheelControl>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// FixedUpdate is called at a fixed time interval
|
||||||
|
void FixedUpdate()
|
||||||
|
{
|
||||||
|
// Read the Vector2 input from the new Input System
|
||||||
|
Vector2 inputVector = carControls.Car.Movement.ReadValue<Vector2>();
|
||||||
|
|
||||||
|
// Get player input for acceleration and steering
|
||||||
|
float vInput = inputVector.y; // Forward/backward input
|
||||||
|
float hInput = inputVector.x; // Steering input
|
||||||
|
|
||||||
|
// Calculate current speed along the car's forward axis
|
||||||
|
float forwardSpeed = Vector3.Dot(transform.forward, rigidBody.linearVelocity);
|
||||||
|
float speedFactor = Mathf.InverseLerp(0, maxSpeed, Mathf.Abs(forwardSpeed)); // Normalized speed factor
|
||||||
|
|
||||||
|
// Reduce motor torque and steering at high speeds for better handling
|
||||||
|
float currentMotorTorque = Mathf.Lerp(motorTorque, 0, speedFactor);
|
||||||
|
float currentSteerRange = Mathf.Lerp(steeringRange, steeringRangeAtMaxSpeed, speedFactor);
|
||||||
|
|
||||||
|
// Determine if the player is accelerating or trying to reverse
|
||||||
|
bool isAccelerating = Mathf.Sign(vInput) == Mathf.Sign(forwardSpeed);
|
||||||
|
|
||||||
|
foreach (var wheel in wheels)
|
||||||
|
{
|
||||||
|
// Apply steering to wheels that support steering
|
||||||
|
if (wheel.steerable)
|
||||||
|
{
|
||||||
|
wheel.WheelCollider.steerAngle = hInput * currentSteerRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAccelerating)
|
||||||
|
{
|
||||||
|
// Apply torque to motorized wheels
|
||||||
|
if (wheel.motorized)
|
||||||
|
{
|
||||||
|
wheel.WheelCollider.motorTorque = vInput * currentMotorTorque;
|
||||||
|
}
|
||||||
|
// Release brakes when accelerating
|
||||||
|
wheel.WheelCollider.brakeTorque = 0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Apply brakes when reversing direction
|
||||||
|
wheel.WheelCollider.motorTorque = 0f;
|
||||||
|
wheel.WheelCollider.brakeTorque = Mathf.Abs(vInput) * brakeTorque;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Car/Scripts/Car/CarControl.cs.meta
Normal file
2
Assets/Car/Scripts/Car/CarControl.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0665500128106154f8d28bace7476416
|
||||||
355
Assets/Car/Scripts/Car/CarInputActions.cs
Normal file
355
Assets/Car/Scripts/Car/CarInputActions.cs
Normal file
@@ -0,0 +1,355 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
|
||||||
|
// version 1.14.0
|
||||||
|
// from Assets/Car/CarInputActions.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;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides programmatic access to <see cref="InputActionAsset" />, <see cref="InputActionMap" />, <see cref="InputAction" /> and <see cref="InputControlScheme" /> instances defined in asset "Assets/Car/CarInputActions.inputactions".
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This class is source generated and any manual edits will be discarded if the associated asset is reimported or modified.
|
||||||
|
/// </remarks>
|
||||||
|
/// <example>
|
||||||
|
/// <code>
|
||||||
|
/// using namespace UnityEngine;
|
||||||
|
/// using UnityEngine.InputSystem;
|
||||||
|
///
|
||||||
|
/// // Example of using an InputActionMap named "Player" from a UnityEngine.MonoBehaviour implementing callback interface.
|
||||||
|
/// public class Example : MonoBehaviour, MyActions.IPlayerActions
|
||||||
|
/// {
|
||||||
|
/// private MyActions_Actions m_Actions; // Source code representation of asset.
|
||||||
|
/// private MyActions_Actions.PlayerActions m_Player; // Source code representation of action map.
|
||||||
|
///
|
||||||
|
/// void Awake()
|
||||||
|
/// {
|
||||||
|
/// m_Actions = new MyActions_Actions(); // Create asset object.
|
||||||
|
/// m_Player = m_Actions.Player; // Extract action map object.
|
||||||
|
/// m_Player.AddCallbacks(this); // Register callback interface IPlayerActions.
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// void OnDestroy()
|
||||||
|
/// {
|
||||||
|
/// m_Actions.Dispose(); // Destroy asset object.
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// void OnEnable()
|
||||||
|
/// {
|
||||||
|
/// m_Player.Enable(); // Enable all actions within map.
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// void OnDisable()
|
||||||
|
/// {
|
||||||
|
/// m_Player.Disable(); // Disable all actions within map.
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// #region Interface implementation of MyActions.IPlayerActions
|
||||||
|
///
|
||||||
|
/// // Invoked when "Move" action is either started, performed or canceled.
|
||||||
|
/// public void OnMove(InputAction.CallbackContext context)
|
||||||
|
/// {
|
||||||
|
/// Debug.Log($"OnMove: {context.ReadValue<Vector2>()}");
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// // Invoked when "Attack" action is either started, performed or canceled.
|
||||||
|
/// public void OnAttack(InputAction.CallbackContext context)
|
||||||
|
/// {
|
||||||
|
/// Debug.Log($"OnAttack: {context.ReadValue<float>()}");
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// #endregion
|
||||||
|
/// }
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
public partial class @CarInputActions: IInputActionCollection2, IDisposable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the underlying asset instance.
|
||||||
|
/// </summary>
|
||||||
|
public InputActionAsset asset { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new instance.
|
||||||
|
/// </summary>
|
||||||
|
public @CarInputActions()
|
||||||
|
{
|
||||||
|
asset = InputActionAsset.FromJson(@"{
|
||||||
|
""name"": ""CarInputActions"",
|
||||||
|
""maps"": [
|
||||||
|
{
|
||||||
|
""name"": ""Car"",
|
||||||
|
""id"": ""c19f950c-3a7a-4a76-8523-1aa6fe6fcc3f"",
|
||||||
|
""actions"": [
|
||||||
|
{
|
||||||
|
""name"": ""Movement"",
|
||||||
|
""type"": ""Value"",
|
||||||
|
""id"": ""a3955e03-93cf-4eb3-aa7e-d47eb8f6589c"",
|
||||||
|
""expectedControlType"": ""Vector2"",
|
||||||
|
""processors"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""initialStateCheck"": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
""bindings"": [
|
||||||
|
{
|
||||||
|
""name"": ""2D Vector"",
|
||||||
|
""id"": ""4acb7ca1-35a7-4da8-8538-b419114f937a"",
|
||||||
|
""path"": ""2DVector"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Movement"",
|
||||||
|
""isComposite"": true,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""up"",
|
||||||
|
""id"": ""7cf87b87-53dc-449a-a3c4-f2e1f37f588a"",
|
||||||
|
""path"": ""<Keyboard>/w"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Movement"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""down"",
|
||||||
|
""id"": ""6f7380e9-0226-4816-92cb-3d668bd040f9"",
|
||||||
|
""path"": ""<Keyboard>/s"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Movement"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""left"",
|
||||||
|
""id"": ""5bf6f0e5-ee39-410a-9997-d4ef3362d1a2"",
|
||||||
|
""path"": ""<Keyboard>/a"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Movement"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""right"",
|
||||||
|
""id"": ""e9e1e925-1395-4159-a82a-b359f9767e77"",
|
||||||
|
""path"": ""<Keyboard>/d"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Movement"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
""controlSchemes"": []
|
||||||
|
}");
|
||||||
|
// Car
|
||||||
|
m_Car = asset.FindActionMap("Car", throwIfNotFound: true);
|
||||||
|
m_Car_Movement = m_Car.FindAction("Movement", throwIfNotFound: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
~@CarInputActions()
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.Assert(!m_Car.enabled, "This will cause a leak and performance issues, CarInputActions.Car.Disable() has not been called.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Destroys this asset and all associated <see cref="InputAction"/> instances.
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
UnityEngine.Object.Destroy(asset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.bindingMask" />
|
||||||
|
public InputBinding? bindingMask
|
||||||
|
{
|
||||||
|
get => asset.bindingMask;
|
||||||
|
set => asset.bindingMask = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.devices" />
|
||||||
|
public ReadOnlyArray<InputDevice>? devices
|
||||||
|
{
|
||||||
|
get => asset.devices;
|
||||||
|
set => asset.devices = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.controlSchemes" />
|
||||||
|
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Contains(InputAction)" />
|
||||||
|
public bool Contains(InputAction action)
|
||||||
|
{
|
||||||
|
return asset.Contains(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.GetEnumerator()" />
|
||||||
|
public IEnumerator<InputAction> GetEnumerator()
|
||||||
|
{
|
||||||
|
return asset.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IEnumerable.GetEnumerator()" />
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Enable()" />
|
||||||
|
public void Enable()
|
||||||
|
{
|
||||||
|
asset.Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Disable()" />
|
||||||
|
public void Disable()
|
||||||
|
{
|
||||||
|
asset.Disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.bindings" />
|
||||||
|
public IEnumerable<InputBinding> bindings => asset.bindings;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.FindAction(string, bool)" />
|
||||||
|
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
|
||||||
|
{
|
||||||
|
return asset.FindAction(actionNameOrId, throwIfNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.FindBinding(InputBinding, out InputAction)" />
|
||||||
|
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;
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to input actions defined in input action map "Car".
|
||||||
|
/// </summary>
|
||||||
|
public struct CarActions
|
||||||
|
{
|
||||||
|
private @CarInputActions m_Wrapper;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Construct a new instance of the input action map wrapper class.
|
||||||
|
/// </summary>
|
||||||
|
public CarActions(@CarInputActions wrapper) { m_Wrapper = wrapper; }
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the underlying input action "Car/Movement".
|
||||||
|
/// </summary>
|
||||||
|
public InputAction @Movement => m_Wrapper.m_Car_Movement;
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to the underlying input action map instance.
|
||||||
|
/// </summary>
|
||||||
|
public InputActionMap Get() { return m_Wrapper.m_Car; }
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Enable()" />
|
||||||
|
public void Enable() { Get().Enable(); }
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Disable()" />
|
||||||
|
public void Disable() { Get().Disable(); }
|
||||||
|
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.enabled" />
|
||||||
|
public bool enabled => Get().enabled;
|
||||||
|
/// <summary>
|
||||||
|
/// Implicitly converts an <see ref="CarActions" /> to an <see ref="InputActionMap" /> instance.
|
||||||
|
/// </summary>
|
||||||
|
public static implicit operator InputActionMap(CarActions set) { return set.Get(); }
|
||||||
|
/// <summary>
|
||||||
|
/// Adds <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="instance">Callback instance.</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// If <paramref name="instance" /> is <c>null</c> or <paramref name="instance"/> have already been added this method does nothing.
|
||||||
|
/// </remarks>
|
||||||
|
/// <seealso cref="CarActions" />
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Calling this method when <paramref name="instance" /> have not previously been registered has no side-effects.
|
||||||
|
/// </remarks>
|
||||||
|
/// <seealso cref="CarActions" />
|
||||||
|
private void UnregisterCallbacks(ICarActions instance)
|
||||||
|
{
|
||||||
|
@Movement.started -= instance.OnMovement;
|
||||||
|
@Movement.performed -= instance.OnMovement;
|
||||||
|
@Movement.canceled -= instance.OnMovement;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unregisters <param cref="instance" /> and unregisters all input action callbacks via <see cref="CarActions.UnregisterCallbacks(ICarActions)" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="CarActions.UnregisterCallbacks(ICarActions)" />
|
||||||
|
public void RemoveCallbacks(ICarActions instance)
|
||||||
|
{
|
||||||
|
if (m_Wrapper.m_CarActionsCallbackInterfaces.Remove(instance))
|
||||||
|
UnregisterCallbacks(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces all existing callback instances and previously registered input action callbacks associated with them with callbacks provided via <param cref="instance" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// If <paramref name="instance" /> is <c>null</c>, calling this method will only unregister all existing callbacks but not register any new callbacks.
|
||||||
|
/// </remarks>
|
||||||
|
/// <seealso cref="CarActions.AddCallbacks(ICarActions)" />
|
||||||
|
/// <seealso cref="CarActions.RemoveCallbacks(ICarActions)" />
|
||||||
|
/// <seealso cref="CarActions.UnregisterCallbacks(ICarActions)" />
|
||||||
|
public void SetCallbacks(ICarActions instance)
|
||||||
|
{
|
||||||
|
foreach (var item in m_Wrapper.m_CarActionsCallbackInterfaces)
|
||||||
|
UnregisterCallbacks(item);
|
||||||
|
m_Wrapper.m_CarActionsCallbackInterfaces.Clear();
|
||||||
|
AddCallbacks(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Provides a new <see cref="CarActions" /> instance referencing this action map.
|
||||||
|
/// </summary>
|
||||||
|
public CarActions @Car => new CarActions(this);
|
||||||
|
/// <summary>
|
||||||
|
/// Interface to implement callback methods for all input action callbacks associated with input actions defined by "Car" which allows adding and removing callbacks.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="CarActions.AddCallbacks(ICarActions)" />
|
||||||
|
/// <seealso cref="CarActions.RemoveCallbacks(ICarActions)" />
|
||||||
|
public interface ICarActions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Method invoked when associated input action "Movement" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||||
|
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||||
|
void OnMovement(InputAction.CallbackContext context);
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Car/Scripts/Car/CarInputActions.cs.meta
Normal file
2
Assets/Car/Scripts/Car/CarInputActions.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ce4bc8ceb06ac494c929dc2ee1148479
|
||||||
78
Assets/Car/Scripts/Car/CarInputActions.inputactions
Normal file
78
Assets/Car/Scripts/Car/CarInputActions.inputactions
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
{
|
||||||
|
"name": "CarInputActions",
|
||||||
|
"maps": [
|
||||||
|
{
|
||||||
|
"name": "Car",
|
||||||
|
"id": "c19f950c-3a7a-4a76-8523-1aa6fe6fcc3f",
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"name": "Movement",
|
||||||
|
"type": "Value",
|
||||||
|
"id": "a3955e03-93cf-4eb3-aa7e-d47eb8f6589c",
|
||||||
|
"expectedControlType": "Vector2",
|
||||||
|
"processors": "",
|
||||||
|
"interactions": "",
|
||||||
|
"initialStateCheck": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bindings": [
|
||||||
|
{
|
||||||
|
"name": "2D Vector",
|
||||||
|
"id": "4acb7ca1-35a7-4da8-8538-b419114f937a",
|
||||||
|
"path": "2DVector",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "",
|
||||||
|
"action": "Movement",
|
||||||
|
"isComposite": true,
|
||||||
|
"isPartOfComposite": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "up",
|
||||||
|
"id": "7cf87b87-53dc-449a-a3c4-f2e1f37f588a",
|
||||||
|
"path": "<Keyboard>/w",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "",
|
||||||
|
"action": "Movement",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "down",
|
||||||
|
"id": "6f7380e9-0226-4816-92cb-3d668bd040f9",
|
||||||
|
"path": "<Keyboard>/s",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "",
|
||||||
|
"action": "Movement",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "left",
|
||||||
|
"id": "5bf6f0e5-ee39-410a-9997-d4ef3362d1a2",
|
||||||
|
"path": "<Keyboard>/a",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "",
|
||||||
|
"action": "Movement",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "right",
|
||||||
|
"id": "e9e1e925-1395-4159-a82a-b359f9767e77",
|
||||||
|
"path": "<Keyboard>/d",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "",
|
||||||
|
"action": "Movement",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"controlSchemes": []
|
||||||
|
}
|
||||||
14
Assets/Car/Scripts/Car/CarInputActions.inputactions.meta
Normal file
14
Assets/Car/Scripts/Car/CarInputActions.inputactions.meta
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 686e90d9bee6e9d4cbff2ff59322f557
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||||
|
generateWrapperCode: 1
|
||||||
|
wrapperCodePath:
|
||||||
|
wrapperClassName:
|
||||||
|
wrapperCodeNamespace:
|
||||||
8
Assets/Car/Scripts/Wheel.meta
Normal file
8
Assets/Car/Scripts/Wheel.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cd085837d46452c48aecbbfa157c4346
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Car/Scripts/Wheel/Scripts.meta
Normal file
8
Assets/Car/Scripts/Wheel/Scripts.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 59f3eacb95253684196cdabaa94f41f6
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
33
Assets/Car/Scripts/Wheel/Scripts/WheelControll.cs
Normal file
33
Assets/Car/Scripts/Wheel/Scripts/WheelControll.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class WheelControl : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Transform wheelModel;
|
||||||
|
|
||||||
|
[HideInInspector] public WheelCollider WheelCollider;
|
||||||
|
|
||||||
|
// Create properties for the CarControl script
|
||||||
|
// (You should enable/disable these via the
|
||||||
|
// Editor Inspector window)
|
||||||
|
public bool steerable;
|
||||||
|
public bool motorized;
|
||||||
|
|
||||||
|
Vector3 position;
|
||||||
|
Quaternion rotation;
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
WheelCollider = GetComponent<WheelCollider>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
// Get the Wheel collider's world pose values and
|
||||||
|
// use them to set the wheel model's position and rotation
|
||||||
|
WheelCollider.GetWorldPose(out position, out rotation);
|
||||||
|
wheelModel.transform.position = position;
|
||||||
|
wheelModel.transform.rotation = rotation;
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Car/Scripts/Wheel/Scripts/WheelControll.cs.meta
Normal file
2
Assets/Car/Scripts/Wheel/Scripts/WheelControll.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 484c6bad1888141449bbccb931f4b3cf
|
||||||
BIN
Assets/Car/car.fbx
Normal file
BIN
Assets/Car/car.fbx
Normal file
Binary file not shown.
117
Assets/Car/car.fbx.meta
Normal file
117
Assets/Car/car.fbx.meta
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cde3b92d14d0b0349b04a21a7734f7fd
|
||||||
|
ModelImporter:
|
||||||
|
serializedVersion: 22200
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects:
|
||||||
|
- first:
|
||||||
|
type: UnityEngine:Texture2D
|
||||||
|
assembly: UnityEngine.CoreModule
|
||||||
|
name: Car Body
|
||||||
|
second: {fileID: 2800000, guid: 0601a27fa7aa1744287b8b9ea1308280, type: 3}
|
||||||
|
- first:
|
||||||
|
type: UnityEngine:Texture2D
|
||||||
|
assembly: UnityEngine.CoreModule
|
||||||
|
name: wheel
|
||||||
|
second: {fileID: 2800000, guid: 6369c12d002a1b348a0f853abe43a22d, type: 3}
|
||||||
|
materials:
|
||||||
|
materialImportMode: 2
|
||||||
|
materialName: 0
|
||||||
|
materialSearch: 1
|
||||||
|
materialLocation: 1
|
||||||
|
animations:
|
||||||
|
legacyGenerateAnimations: 4
|
||||||
|
bakeSimulation: 0
|
||||||
|
resampleCurves: 1
|
||||||
|
optimizeGameObjects: 0
|
||||||
|
removeConstantScaleCurves: 0
|
||||||
|
motionNodeName:
|
||||||
|
animationImportErrors:
|
||||||
|
animationImportWarnings:
|
||||||
|
animationRetargetingWarnings:
|
||||||
|
animationDoRetargetingWarnings: 0
|
||||||
|
importAnimatedCustomProperties: 0
|
||||||
|
importConstraints: 0
|
||||||
|
animationCompression: 1
|
||||||
|
animationRotationError: 0.5
|
||||||
|
animationPositionError: 0.5
|
||||||
|
animationScaleError: 0.5
|
||||||
|
animationWrapMode: 0
|
||||||
|
extraExposedTransformPaths: []
|
||||||
|
extraUserProperties: []
|
||||||
|
clipAnimations: []
|
||||||
|
isReadable: 0
|
||||||
|
meshes:
|
||||||
|
lODScreenPercentages: []
|
||||||
|
globalScale: 1
|
||||||
|
meshCompression: 0
|
||||||
|
addColliders: 0
|
||||||
|
useSRGBMaterialColor: 1
|
||||||
|
sortHierarchyByName: 1
|
||||||
|
importPhysicalCameras: 1
|
||||||
|
importVisibility: 1
|
||||||
|
importBlendShapes: 1
|
||||||
|
importCameras: 1
|
||||||
|
importLights: 1
|
||||||
|
nodeNameCollisionStrategy: 1
|
||||||
|
fileIdsGeneration: 2
|
||||||
|
swapUVChannels: 0
|
||||||
|
generateSecondaryUV: 0
|
||||||
|
useFileUnits: 1
|
||||||
|
keepQuads: 0
|
||||||
|
weldVertices: 1
|
||||||
|
bakeAxisConversion: 0
|
||||||
|
preserveHierarchy: 0
|
||||||
|
skinWeightsMode: 0
|
||||||
|
maxBonesPerVertex: 4
|
||||||
|
minBoneWeight: 0.001
|
||||||
|
optimizeBones: 1
|
||||||
|
meshOptimizationFlags: -1
|
||||||
|
indexFormat: 0
|
||||||
|
secondaryUVAngleDistortion: 8
|
||||||
|
secondaryUVAreaDistortion: 15.000001
|
||||||
|
secondaryUVHardAngle: 88
|
||||||
|
secondaryUVMarginMethod: 1
|
||||||
|
secondaryUVMinLightmapResolution: 40
|
||||||
|
secondaryUVMinObjectScale: 1
|
||||||
|
secondaryUVPackMargin: 4
|
||||||
|
useFileScale: 1
|
||||||
|
strictVertexDataChecks: 0
|
||||||
|
tangentSpace:
|
||||||
|
normalSmoothAngle: 60
|
||||||
|
normalImportMode: 0
|
||||||
|
tangentImportMode: 3
|
||||||
|
normalCalculationMode: 4
|
||||||
|
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
||||||
|
blendShapeNormalImportMode: 1
|
||||||
|
normalSmoothingSource: 0
|
||||||
|
referencedClips: []
|
||||||
|
importAnimation: 1
|
||||||
|
humanDescription:
|
||||||
|
serializedVersion: 3
|
||||||
|
human: []
|
||||||
|
skeleton: []
|
||||||
|
armTwist: 0.5
|
||||||
|
foreArmTwist: 0.5
|
||||||
|
upperLegTwist: 0.5
|
||||||
|
legTwist: 0.5
|
||||||
|
armStretch: 0.05
|
||||||
|
legStretch: 0.05
|
||||||
|
feetSpacing: 0
|
||||||
|
globalScale: 1
|
||||||
|
rootMotionBoneName:
|
||||||
|
hasTranslationDoF: 0
|
||||||
|
hasExtraRoot: 0
|
||||||
|
skeletonHasParents: 1
|
||||||
|
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||||
|
autoGenerateAvatarMappingIfUnspecified: 1
|
||||||
|
animationType: 2
|
||||||
|
humanoidOversampling: 1
|
||||||
|
avatarSetup: 0
|
||||||
|
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
|
||||||
|
importBlendShapeDeformPercent: 1
|
||||||
|
remapMaterialsIfMaterialImportModeIsNone: 0
|
||||||
|
additionalBone: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Character.meta
Normal file
8
Assets/Character.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5be90bf5c38796546af4cbf973c39085
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Character/Scripts.meta
Normal file
8
Assets/Character/Scripts.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ab7d5486bef4e974087db69b0c307254
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
43
Assets/Character/Scripts/CharacterMovementCotroller.cs
Normal file
43
Assets/Character/Scripts/CharacterMovementCotroller.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
public class CharacterMovementCotroller : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
[SerializeField] float driveSpeed = 10f;
|
||||||
|
[SerializeField] float turnSpeed = 1000f;
|
||||||
|
|
||||||
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
EvaluateMovementInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector3 turnLeft = new Vector3(0, -1, 0);
|
||||||
|
private Vector3 turnRight = new Vector3(0, 1, 0);
|
||||||
|
|
||||||
|
void EvaluateMovementInput() {
|
||||||
|
Quaternion currentRotation = transform.rotation;
|
||||||
|
if (Keyboard.current.wKey.isPressed) {
|
||||||
|
Vector3 moveBy = transform.forward * driveSpeed * Time.deltaTime;
|
||||||
|
transform.position += moveBy;
|
||||||
|
}
|
||||||
|
if (Keyboard.current.sKey.isPressed) {
|
||||||
|
Vector3 moveBy = transform.forward * -1 * driveSpeed * Time.deltaTime;
|
||||||
|
transform.position += moveBy;
|
||||||
|
}
|
||||||
|
if (Keyboard.current.aKey.isPressed) {
|
||||||
|
transform.Rotate(turnLeft * Time.deltaTime * turnSpeed);
|
||||||
|
}
|
||||||
|
if (Keyboard.current.dKey.isPressed) {
|
||||||
|
transform.Rotate(turnRight * Time.deltaTime * turnSpeed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 30b89096a634b634ea818091dae0462f
|
||||||
1173
Assets/Scenes/TestBed.unity
Normal file
1173
Assets/Scenes/TestBed.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Scenes/TestBed.unity.meta
Normal file
7
Assets/Scenes/TestBed.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ba9b44b18b68a7c4fa5522f486b7168f
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/wheel.jpg
Normal file
BIN
Assets/wheel.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
130
Assets/wheel.jpg.meta
Normal file
130
Assets/wheel.jpg.meta
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6369c12d002a1b348a0f853abe43a22d
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 13
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
flipGreenChannel: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
|
ignoreMipmapLimit: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: 1
|
||||||
|
aniso: 1
|
||||||
|
mipBias: 0
|
||||||
|
wrapU: 0
|
||||||
|
wrapV: 0
|
||||||
|
wrapW: 0
|
||||||
|
nPOTScale: 1
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 0
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 0
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 0
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
|
applyGammaDecoding: 0
|
||||||
|
swizzle: 50462976
|
||||||
|
cookieLightType: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: WebGL
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
customData:
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID:
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
spriteCustomMetadata:
|
||||||
|
entries: []
|
||||||
|
nameFileIdTable: {}
|
||||||
|
mipmapLimitGroupName:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
121
ProjectSettings/SceneTemplateSettings.json
Normal file
121
ProjectSettings/SceneTemplateSettings.json
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
{
|
||||||
|
"templatePinStates": [],
|
||||||
|
"dependencyTypeInfos": [
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.AnimationClip",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEditor.Animations.AnimatorController",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.AnimatorOverrideController",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEditor.Audio.AudioMixerController",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.ComputeShader",
|
||||||
|
"defaultInstantiationMode": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.Cubemap",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.GameObject",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEditor.LightingDataAsset",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.LightingSettings",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.Material",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEditor.MonoScript",
|
||||||
|
"defaultInstantiationMode": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.PhysicsMaterial",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.PhysicsMaterial2D",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.Rendering.PostProcessing.PostProcessResources",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.Rendering.VolumeProfile",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEditor.SceneAsset",
|
||||||
|
"defaultInstantiationMode": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.Shader",
|
||||||
|
"defaultInstantiationMode": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.ShaderVariantCollection",
|
||||||
|
"defaultInstantiationMode": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.Texture",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.Texture2D",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "UnityEngine.Timeline.TimelineAsset",
|
||||||
|
"defaultInstantiationMode": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"defaultDependencyTypeInfo": {
|
||||||
|
"userAdded": false,
|
||||||
|
"type": "<default_scene_template_dependencies>",
|
||||||
|
"defaultInstantiationMode": 1
|
||||||
|
},
|
||||||
|
"newSceneOverride": 0
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user