@ -0,0 +1,126 @@ | |||
%YAML 1.1 | |||
%TAG !u! tag:unity3d.com,2011: | |||
--- !u!114 &-3652684074043160694 | |||
MonoBehaviour: | |||
m_ObjectHideFlags: 11 | |||
m_CorrespondingSourceObject: {fileID: 0} | |||
m_PrefabInstance: {fileID: 0} | |||
m_PrefabAsset: {fileID: 0} | |||
m_GameObject: {fileID: 0} | |||
m_Enabled: 1 | |||
m_EditorHideFlags: 0 | |||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} | |||
m_Name: | |||
m_EditorClassIdentifier: | |||
version: 5 | |||
--- !u!21 &2100000 | |||
Material: | |||
serializedVersion: 8 | |||
m_ObjectHideFlags: 0 | |||
m_CorrespondingSourceObject: {fileID: 0} | |||
m_PrefabInstance: {fileID: 0} | |||
m_PrefabAsset: {fileID: 0} | |||
m_Name: New Material 1 | |||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} | |||
m_ValidKeywords: [] | |||
m_InvalidKeywords: [] | |||
m_LightmapFlags: 4 | |||
m_EnableInstancingVariants: 0 | |||
m_DoubleSidedGI: 0 | |||
m_CustomRenderQueue: -1 | |||
stringTagMap: | |||
RenderType: Opaque | |||
disabledShaderPasses: [] | |||
m_SavedProperties: | |||
serializedVersion: 3 | |||
m_TexEnvs: | |||
- _BaseMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _BumpMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _DetailAlbedoMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _DetailMask: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _DetailNormalMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _EmissionMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _MainTex: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _MetallicGlossMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _OcclusionMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _ParallaxMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _SpecGlossMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- unity_Lightmaps: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- unity_LightmapsInd: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- unity_ShadowMasks: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
m_Ints: [] | |||
m_Floats: | |||
- _AlphaClip: 0 | |||
- _Blend: 0 | |||
- _BumpScale: 1 | |||
- _ClearCoatMask: 0 | |||
- _ClearCoatSmoothness: 0 | |||
- _Cull: 2 | |||
- _Cutoff: 0.5 | |||
- _DetailAlbedoMapScale: 1 | |||
- _DetailNormalMapScale: 1 | |||
- _DstBlend: 0 | |||
- _EnvironmentReflections: 1 | |||
- _GlossMapScale: 0 | |||
- _Glossiness: 0 | |||
- _GlossyReflections: 0 | |||
- _Metallic: 0 | |||
- _OcclusionStrength: 1 | |||
- _Parallax: 0.005 | |||
- _QueueOffset: 0 | |||
- _ReceiveShadows: 1 | |||
- _Smoothness: 0 | |||
- _SmoothnessTextureChannel: 0 | |||
- _SpecularHighlights: 1 | |||
- _SrcBlend: 1 | |||
- _Surface: 0 | |||
- _WorkflowMode: 1 | |||
- _ZWrite: 1 | |||
m_Colors: | |||
- _BaseColor: {r: 0, g: 0.5085707, b: 1, a: 1} | |||
- _Color: {r: 0, g: 0.5085706, b: 1, a: 1} | |||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} | |||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} | |||
m_BuildTextureStacks: [] |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: 5095da6df021aa344ba98f4a950d03f2 | |||
NativeFormatImporter: | |||
externalObjects: {} | |||
mainObjectFileID: 2100000 | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,126 @@ | |||
%YAML 1.1 | |||
%TAG !u! tag:unity3d.com,2011: | |||
--- !u!114 &-3652684074043160694 | |||
MonoBehaviour: | |||
m_ObjectHideFlags: 11 | |||
m_CorrespondingSourceObject: {fileID: 0} | |||
m_PrefabInstance: {fileID: 0} | |||
m_PrefabAsset: {fileID: 0} | |||
m_GameObject: {fileID: 0} | |||
m_Enabled: 1 | |||
m_EditorHideFlags: 0 | |||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} | |||
m_Name: | |||
m_EditorClassIdentifier: | |||
version: 5 | |||
--- !u!21 &2100000 | |||
Material: | |||
serializedVersion: 8 | |||
m_ObjectHideFlags: 0 | |||
m_CorrespondingSourceObject: {fileID: 0} | |||
m_PrefabInstance: {fileID: 0} | |||
m_PrefabAsset: {fileID: 0} | |||
m_Name: New Material 2 | |||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} | |||
m_ValidKeywords: [] | |||
m_InvalidKeywords: [] | |||
m_LightmapFlags: 4 | |||
m_EnableInstancingVariants: 0 | |||
m_DoubleSidedGI: 0 | |||
m_CustomRenderQueue: -1 | |||
stringTagMap: | |||
RenderType: Opaque | |||
disabledShaderPasses: [] | |||
m_SavedProperties: | |||
serializedVersion: 3 | |||
m_TexEnvs: | |||
- _BaseMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _BumpMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _DetailAlbedoMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _DetailMask: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _DetailNormalMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _EmissionMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _MainTex: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _MetallicGlossMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _OcclusionMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _ParallaxMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _SpecGlossMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- unity_Lightmaps: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- unity_LightmapsInd: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- unity_ShadowMasks: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
m_Ints: [] | |||
m_Floats: | |||
- _AlphaClip: 0 | |||
- _Blend: 0 | |||
- _BumpScale: 1 | |||
- _ClearCoatMask: 0 | |||
- _ClearCoatSmoothness: 0 | |||
- _Cull: 2 | |||
- _Cutoff: 0.5 | |||
- _DetailAlbedoMapScale: 1 | |||
- _DetailNormalMapScale: 1 | |||
- _DstBlend: 0 | |||
- _EnvironmentReflections: 1 | |||
- _GlossMapScale: 0 | |||
- _Glossiness: 0 | |||
- _GlossyReflections: 0 | |||
- _Metallic: 0 | |||
- _OcclusionStrength: 1 | |||
- _Parallax: 0.005 | |||
- _QueueOffset: 0 | |||
- _ReceiveShadows: 1 | |||
- _Smoothness: 0 | |||
- _SmoothnessTextureChannel: 0 | |||
- _SpecularHighlights: 1 | |||
- _SrcBlend: 1 | |||
- _Surface: 0 | |||
- _WorkflowMode: 1 | |||
- _ZWrite: 1 | |||
m_Colors: | |||
- _BaseColor: {r: 0.6509434, g: 0.36700508, b: 0, a: 1} | |||
- _Color: {r: 0.6509434, g: 0.36700505, b: 0, a: 1} | |||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} | |||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} | |||
m_BuildTextureStacks: [] |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: 13b12a03fb52a1249a43addf2c182980 | |||
NativeFormatImporter: | |||
externalObjects: {} | |||
mainObjectFileID: 2100000 | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,126 @@ | |||
%YAML 1.1 | |||
%TAG !u! tag:unity3d.com,2011: | |||
--- !u!114 &-3652684074043160694 | |||
MonoBehaviour: | |||
m_ObjectHideFlags: 11 | |||
m_CorrespondingSourceObject: {fileID: 0} | |||
m_PrefabInstance: {fileID: 0} | |||
m_PrefabAsset: {fileID: 0} | |||
m_GameObject: {fileID: 0} | |||
m_Enabled: 1 | |||
m_EditorHideFlags: 0 | |||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} | |||
m_Name: | |||
m_EditorClassIdentifier: | |||
version: 5 | |||
--- !u!21 &2100000 | |||
Material: | |||
serializedVersion: 8 | |||
m_ObjectHideFlags: 0 | |||
m_CorrespondingSourceObject: {fileID: 0} | |||
m_PrefabInstance: {fileID: 0} | |||
m_PrefabAsset: {fileID: 0} | |||
m_Name: New Material | |||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} | |||
m_ValidKeywords: [] | |||
m_InvalidKeywords: [] | |||
m_LightmapFlags: 4 | |||
m_EnableInstancingVariants: 0 | |||
m_DoubleSidedGI: 0 | |||
m_CustomRenderQueue: -1 | |||
stringTagMap: | |||
RenderType: Opaque | |||
disabledShaderPasses: [] | |||
m_SavedProperties: | |||
serializedVersion: 3 | |||
m_TexEnvs: | |||
- _BaseMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _BumpMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _DetailAlbedoMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _DetailMask: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _DetailNormalMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _EmissionMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _MainTex: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _MetallicGlossMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _OcclusionMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _ParallaxMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- _SpecGlossMap: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- unity_Lightmaps: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- unity_LightmapsInd: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
- unity_ShadowMasks: | |||
m_Texture: {fileID: 0} | |||
m_Scale: {x: 1, y: 1} | |||
m_Offset: {x: 0, y: 0} | |||
m_Ints: [] | |||
m_Floats: | |||
- _AlphaClip: 0 | |||
- _Blend: 0 | |||
- _BumpScale: 1 | |||
- _ClearCoatMask: 0 | |||
- _ClearCoatSmoothness: 0 | |||
- _Cull: 2 | |||
- _Cutoff: 0.5 | |||
- _DetailAlbedoMapScale: 1 | |||
- _DetailNormalMapScale: 1 | |||
- _DstBlend: 0 | |||
- _EnvironmentReflections: 1 | |||
- _GlossMapScale: 0 | |||
- _Glossiness: 0 | |||
- _GlossyReflections: 0 | |||
- _Metallic: 0 | |||
- _OcclusionStrength: 1 | |||
- _Parallax: 0.005 | |||
- _QueueOffset: 0 | |||
- _ReceiveShadows: 1 | |||
- _Smoothness: 0 | |||
- _SmoothnessTextureChannel: 0 | |||
- _SpecularHighlights: 1 | |||
- _SrcBlend: 1 | |||
- _Surface: 0 | |||
- _WorkflowMode: 1 | |||
- _ZWrite: 1 | |||
m_Colors: | |||
- _BaseColor: {r: 0.041586675, g: 0.7264151, b: 0, a: 1} | |||
- _Color: {r: 0.041586652, g: 0.7264151, b: 0, a: 1} | |||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} | |||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} | |||
m_BuildTextureStacks: [] |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: 43a303477ba752346bfd0a5356ca7e05 | |||
NativeFormatImporter: | |||
externalObjects: {} | |||
mainObjectFileID: 2100000 | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
size 21839 |
@ -0,0 +1,7 @@ | |||
fileFormatVersion: 2 | |||
guid: 72514749158858a4e8977db04e36b05a | |||
PrefabImporter: | |||
externalObjects: {} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
size 47466 |
@ -0,0 +1,7 @@ | |||
fileFormatVersion: 2 | |||
guid: 904515e4b7bd3e04fa051e50eb9a2eae | |||
DefaultImporter: | |||
externalObjects: {} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,8 @@ | |||
fileFormatVersion: 2 | |||
guid: 1b8532fcb1449a640a09b4cdf120171e | |||
folderAsset: yes | |||
DefaultImporter: | |||
externalObjects: {} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
size 17564 |
@ -0,0 +1,7 @@ | |||
fileFormatVersion: 2 | |||
guid: 08c61a126f535e24592d442f7d72b045 | |||
DefaultImporter: | |||
externalObjects: {} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,76 @@ | |||
using System.Collections; | |||
using System.Collections.Generic; | |||
using UnityEngine; | |||
using UnityEngine.InputSystem; | |||
public class BoatController : MonoBehaviour | |||
{ | |||
private Rigidbody rigidBody; | |||
[SerializeField] | |||
private float ForwardFactor = 1f; | |||
[SerializeField] | |||
private float RotationFactor = 1f; | |||
[SerializeField] | |||
private float BrakeFactor = 1f; | |||
void Awake() | |||
{ | |||
rigidBody = GetComponent<Rigidbody>(); | |||
} | |||
// Update is called once per frame | |||
void Update() | |||
{ | |||
//get input | |||
if (Input.GetKeyDown(KeyCode.A)) | |||
{ | |||
RowLeft(); | |||
} | |||
if (Input.GetKeyDown(KeyCode.D)) | |||
{ | |||
RowRight(); | |||
} | |||
if (Input.GetKeyDown(KeyCode.S)) | |||
{ | |||
Brake(); | |||
} | |||
} | |||
private void FixedUpdate() | |||
{ | |||
print(transform.rotation.eulerAngles.y); | |||
//constrain rotation | |||
if (transform.rotation.eulerAngles.y > 180 && transform.rotation.eulerAngles.y < 270) | |||
{ | |||
print("under"); | |||
transform.rotation = Quaternion.Euler(new Vector3(0f, 270f, 0f)); | |||
rigidBody.angularVelocity = Vector3.zero; | |||
} | |||
//constrain rotation | |||
if (transform.rotation.eulerAngles.y < 180 && transform.rotation.eulerAngles.y > 90f) | |||
{ | |||
print("over"); | |||
transform.rotation = Quaternion.Euler(new Vector3(0f, 90f, 0f)); | |||
rigidBody.angularVelocity = Vector3.zero; | |||
} | |||
} | |||
public void RowLeft() | |||
{ | |||
rigidBody.AddForce(transform.forward * ForwardFactor, ForceMode.Acceleration); | |||
rigidBody.AddTorque(transform.up * -RotationFactor); | |||
} | |||
public void RowRight() | |||
{ | |||
rigidBody.AddForce(transform.forward * ForwardFactor, ForceMode.Acceleration); | |||
rigidBody.AddTorque(transform.up * RotationFactor); | |||
} | |||
public void Brake() | |||
{ | |||
rigidBody.AddForce(rigidBody.velocity * - BrakeFactor); | |||
rigidBody.AddTorque(rigidBody.angularVelocity * -BrakeFactor); | |||
} | |||
} |
@ -0,0 +1,11 @@ | |||
fileFormatVersion: 2 | |||
guid: 86234d79603585f47baa7cf82d12d2df | |||
MonoImporter: | |||
externalObjects: {} | |||
serializedVersion: 2 | |||
defaultReferences: [] | |||
executionOrder: 0 | |||
icon: {instanceID: 0} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,156 @@ | |||
using System.Collections; | |||
using System.Collections.Generic; | |||
using UnityEngine; | |||
using UnityEngine.InputSystem; | |||
using NaughtyAttributes; | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public class HandController : MonoBehaviour | |||
{ | |||
#region Inspector Fields | |||
[SerializeField, BoxGroup("References")] | |||
private Transform m_handTransform; | |||
[SerializeField] | |||
private Transform m_otherHand; | |||
[SerializeField, BoxGroup("Settings")] | |||
private Vector3 m_axisNormal = Vector3.forward; | |||
[SerializeField, BoxGroup("Settings")] | |||
private Vector3 m_axisForward = Vector3.up; | |||
[SerializeField, BoxGroup("Settings")] | |||
private float m_armRange = 1; | |||
[SerializeField, BoxGroup("Settings"),Range(0.0f,1.0f)] | |||
private float m_armSpeed = 0.5f; | |||
[SerializeField, BoxGroup("Input")] | |||
private InputActionProperty m_inputAxis; | |||
[SerializeField, BoxGroup("Input")] | |||
private InputActionProperty m_row; | |||
#endregion Inspector Fields | |||
#region Private Fields | |||
//Last input of player | |||
private Vector2 m_desiredInput; | |||
private Vector3 m_startPosition; | |||
private Vector3 m_lastPosition; | |||
#endregion Private Fields | |||
#region Getters | |||
public new Transform transform => m_handTransform; | |||
#endregion Getters | |||
#region MonoBehaviour Functions | |||
private void Start() | |||
{ | |||
m_startPosition = transform.localPosition; | |||
} | |||
/// <summary> | |||
/// OnEnable is called when the object becomes enabled and active. | |||
/// </summary> | |||
private void OnEnable() | |||
{ | |||
m_inputAxis.action.performed += OnInputRecieved; | |||
m_inputAxis.action.canceled += OnInputRecieved; | |||
m_inputAxis.action.Enable(); | |||
m_row.action?.Enable(); | |||
} | |||
/// <summary> | |||
/// OnDisable is called when the behaviour becomes disabled. | |||
/// </summary> | |||
private void OnDisable() | |||
{ | |||
m_inputAxis.action.performed -= OnInputRecieved; | |||
m_inputAxis.action.canceled -= OnInputRecieved; | |||
m_inputAxis.action.Disable(); | |||
m_row.action?.Disable(); | |||
} | |||
/// <summary> | |||
/// Update is called once per frame | |||
/// </summary> | |||
private void FixedUpdate() | |||
{ | |||
UpdateHand(m_desiredInput); | |||
} | |||
#endregion MonoBehaviour Functions | |||
#region Class Functionality | |||
/// <summary> | |||
/// Called every fixed update to move the arms | |||
/// </summary> | |||
/// <param name="input"></param> | |||
private void UpdateHand(Vector2 input) | |||
{ | |||
m_lastPosition = transform.localPosition; | |||
Quaternion rotation = Quaternion.LookRotation(m_axisForward.normalized, m_axisNormal.normalized); | |||
Vector3 axisInput = transform.rotation * rotation * new Vector3(input.x, 0, input.y); | |||
Vector3 desiredPosition = m_startPosition + axisInput * m_armRange; | |||
transform.localPosition = Vector3.Lerp(transform.localPosition, desiredPosition, m_armSpeed); | |||
if (m_row.action != null) | |||
{ | |||
if (m_row.action.IsPressed()) | |||
{ | |||
transform.localPosition = Vector3.Lerp(transform.localPosition, m_otherHand.localPosition, 0.5f); | |||
} | |||
} | |||
} | |||
public void UndoLastMovement() | |||
{ | |||
transform.localPosition = m_lastPosition; | |||
} | |||
/// <summary> | |||
/// Called by the input system when the input is changed | |||
/// </summary> | |||
/// <param name="args"></param> | |||
private void OnInputRecieved(InputAction.CallbackContext args) | |||
{ | |||
m_desiredInput = args.ReadValue<Vector2>(); | |||
} | |||
#endregion Class Functionality | |||
#region Editor Functions | |||
/// <summary> | |||
/// Called when the Component is created or Reset from the Inspector | |||
/// </summary> | |||
private void Reset() | |||
{ | |||
m_handTransform = base.transform; | |||
} | |||
#endregion Editor Functions | |||
} |
@ -0,0 +1,11 @@ | |||
fileFormatVersion: 2 | |||
guid: 9531ea25ab68fa6428196676e0198eb6 | |||
MonoImporter: | |||
externalObjects: {} | |||
serializedVersion: 2 | |||
defaultReferences: [] | |||
executionOrder: 0 | |||
icon: {instanceID: 0} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -1,18 +1,131 @@ | |||
using System.Collections; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using UnityEngine; | |||
using NaughtyAttributes; | |||
/// <summary> | |||
/// Script to control player input and oars | |||
/// </summary> | |||
public class OarController : MonoBehaviour | |||
{ | |||
// Start is called before the first frame update | |||
void Start() | |||
#region Inspector Fields | |||
[SerializeField,BoxGroup("References")] | |||
private HandController m_leftHand; | |||
[SerializeField, BoxGroup("References")] | |||
private HandController m_rightHand; | |||
[SerializeField, BoxGroup("References")] | |||
private Rigidbody m_oarRigidbody; | |||
[SerializeField, BoxGroup("References")] | |||
private Transform m_body; | |||
[SerializeField] | |||
private List<Collider> m_forbiddenColliders; | |||
#endregion Inspector Fields | |||
#region Private Fields | |||
float m_distanceFromRightHand; | |||
bool undoDoneThisFrame = false; | |||
#endregion Private Fields | |||
#region Getters | |||
public new Transform transform => m_oarRigidbody.transform; | |||
#endregion Getters | |||
#region MonoBehaviour Functions | |||
private void Awake() | |||
{ | |||
m_distanceFromRightHand = Vector3.Distance(m_rightHand.transform.position, transform.position); | |||
m_oarRigidbody = GetComponent<Rigidbody>(); | |||
} | |||
/// <summary> | |||
/// OnEnable is called when the object becomes enabled and active. | |||
/// </summary> | |||
private void OnEnable() | |||
{ | |||
} | |||
// Update is called once per frame | |||
void Update() | |||
/// <summary> | |||
/// OnDisable is called when the behaviour becomes disabled. | |||
/// </summary> | |||
private void OnDisable() | |||
{ | |||
} | |||
/// <summary> | |||
/// Update is called once per frame | |||
/// </summary> | |||
private void FixedUpdate() | |||
{ | |||
undoDoneThisFrame = false; | |||
UpdateTransform(); | |||
} | |||
#endregion MonoBehaviour Functions | |||
#region Class Functionality | |||
private void UpdateTransform() | |||
{ | |||
Vector3 direction =(m_rightHand.transform.position - m_leftHand.transform.position).normalized; | |||
Vector3 forward = Vector3.Cross(direction, m_body.forward); | |||
Quaternion rotation = Quaternion.LookRotation(forward, direction); | |||
m_oarRigidbody.MovePosition(m_rightHand.transform.position - direction * m_distanceFromRightHand); | |||
m_oarRigidbody.MoveRotation(rotation); | |||
} | |||
void OnCollisionEnter(Collision collision) | |||
{ | |||
if (m_forbiddenColliders.Contains(collision.collider) && !undoDoneThisFrame) | |||
{ | |||
Debug.Log($"Forbidden Collision: {collision.collider.gameObject}"); | |||
undoDoneThisFrame= true; | |||
m_leftHand.UndoLastMovement(); | |||
m_rightHand.UndoLastMovement(); | |||
} | |||
else | |||
{ | |||
Debug.Log($"Ignored Collision: {collision.collider.gameObject}"); | |||
} | |||
} | |||
} | |||
#endregion Class Functionality | |||
#region Editor Functions | |||
/// <summary> | |||
/// Called when the Component is created or Reset from the Inspector | |||
/// </summary> | |||
private void Reset() | |||
{ | |||
m_oarRigidbody = GetComponentInChildren<Rigidbody>(); | |||
} | |||
#endregion Editor Functions | |||
} |
@ -0,0 +1,86 @@ | |||
using System.Collections; | |||
using System.Collections.Generic; | |||
using UnityEngine; | |||
using UnityEngine.InputSystem; | |||
using NaughtyAttributes; | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public class RowController : MonoBehaviour | |||
{ | |||
#region Inspector Fields | |||
[SerializeField] | |||
private Transform m_topHand; | |||
[SerializeField] | |||
private Transform m_bottomHand; | |||
[SerializeField, BoxGroup("Settings"), Range(0.0f, 1.0f)] | |||
private float m_armRange = 1; | |||
[SerializeField, BoxGroup("Settings"), Range(0.0f, 1.0f)] | |||
private float m_armSpeed = 0.2f; | |||
[SerializeField, BoxGroup("Input")] | |||
private InputActionProperty m_inputAxis; | |||
#endregion Inspector Fields | |||
#region Private Fields | |||
#endregion Private Fields | |||
#region Getters | |||
#endregion Getters | |||
#region MonoBehaviour Functions | |||
/// <summary> | |||
/// OnEnable is called when the object becomes enabled and active. | |||
/// </summary> | |||
private void OnEnable() | |||
{ | |||
} | |||
/// <summary> | |||
/// OnDisable is called when the behaviour becomes disabled. | |||
/// </summary> | |||
private void OnDisable() | |||
{ | |||
} | |||
/// <summary> | |||
/// Update is called once per frame | |||
/// </summary> | |||
private void Update() | |||
{ | |||
} | |||
#endregion MonoBehaviour Functions | |||
#region Class Functionality | |||
#endregion Class Functionality | |||
#region Editor Functions | |||
/// <summary> | |||
/// Called when the Component is created or Reset from the Inspector | |||
/// </summary> | |||
private void Reset() | |||
{ | |||
//useful for finding components on creation | |||
} | |||
#endregion Editor Functions | |||
} |
@ -0,0 +1,11 @@ | |||
fileFormatVersion: 2 | |||
guid: c8c0b8a0d937577428fa6056801a716a | |||
MonoImporter: | |||
externalObjects: {} | |||
serializedVersion: 2 | |||
defaultReferences: [] | |||
executionOrder: 0 | |||
icon: {instanceID: 0} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -0,0 +1,14 @@ | |||
fileFormatVersion: 2 | |||
guid: 5007e9a2e21d73f43b8fbe101756449d | |||
ScriptedImporter: | |||
internalIDToNameTable: [] | |||
externalObjects: {} | |||
serializedVersion: 2 | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: | |||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3} | |||
generateWrapperCode: 0 | |||
wrapperCodePath: | |||
wrapperClassName: | |||
wrapperCodeNamespace: UnityEngine.InputSystem |
size 1323 |