controller stuff
This commit is contained in:
parent
7b8222da45
commit
aaa20a64d5
|
@ -215,6 +215,99 @@ Transform:
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &107616016
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 107616020}
|
||||||
|
- component: {fileID: 107616021}
|
||||||
|
- component: {fileID: 107616018}
|
||||||
|
- component: {fileID: 107616017}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Player 2
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!50 &107616017
|
||||||
|
Rigidbody2D:
|
||||||
|
serializedVersion: 4
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 107616016}
|
||||||
|
m_BodyType: 0
|
||||||
|
m_Simulated: 1
|
||||||
|
m_UseFullKinematicContacts: 0
|
||||||
|
m_UseAutoMass: 0
|
||||||
|
m_Mass: 1
|
||||||
|
m_LinearDrag: 0
|
||||||
|
m_AngularDrag: 0.05
|
||||||
|
m_GravityScale: 0
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_Interpolate: 0
|
||||||
|
m_SleepingMode: 1
|
||||||
|
m_CollisionDetection: 1
|
||||||
|
m_Constraints: 0
|
||||||
|
--- !u!114 &107616018
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 107616016}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
maxHealth: 100
|
||||||
|
currentHealth: 0
|
||||||
|
healthText: {fileID: 1666646758}
|
||||||
|
--- !u!4 &107616020
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 107616016}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 3.51, y: 1.14, z: -0.09089095}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 1682789264}
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &107616021
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 107616016}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: e891644cda7544948af35b0d2f2c3be2, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
moveSpeed: 5
|
||||||
|
stepCooldown: 0.2
|
||||||
|
stepVibrationTime: 0.05
|
||||||
|
rumble: {fileID: 1744797149}
|
||||||
--- !u!1 &646449334
|
--- !u!1 &646449334
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -317,6 +410,38 @@ RectTransform:
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
m_SizeDelta: {x: 0, y: 0}
|
m_SizeDelta: {x: 0, y: 0}
|
||||||
m_Pivot: {x: 0, y: 0}
|
m_Pivot: {x: 0, y: 0}
|
||||||
|
--- !u!1 &781349953
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 781349954}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: References
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &781349954
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 781349953}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: -0.7082175, y: -0.44170734, z: -0.09089095}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 1744797150}
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &970285067
|
--- !u!1 &970285067
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -412,6 +537,7 @@ GameObject:
|
||||||
- component: {fileID: 1420709241}
|
- component: {fileID: 1420709241}
|
||||||
- component: {fileID: 1420709240}
|
- component: {fileID: 1420709240}
|
||||||
- component: {fileID: 1420709239}
|
- component: {fileID: 1420709239}
|
||||||
|
- component: {fileID: 1420709242}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: EventSystem
|
m_Name: EventSystem
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -469,6 +595,18 @@ Transform:
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &1420709242
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1420709238}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: d79b9b67e3de5ba4590c4e63726f5c8b, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &1666646756
|
--- !u!1 &1666646756
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -603,6 +741,134 @@ CanvasRenderer:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1666646756}
|
m_GameObject: {fileID: 1666646756}
|
||||||
m_CullTransparentMesh: 1
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!1 &1682789263
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1682789264}
|
||||||
|
- component: {fileID: 1682789265}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Renderer
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &1682789264
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1682789263}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0.7082175, y: 0.44170734, z: 0.09089095}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 107616020}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!212 &1682789265
|
||||||
|
SpriteRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1682789263}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 0
|
||||||
|
m_ReceiveShadows: 0
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 0
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 0
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_Sprite: {fileID: -2413806693520163455, guid: a86470a33a6bf42c4b3595704624658b, type: 3}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_FlipX: 0
|
||||||
|
m_FlipY: 0
|
||||||
|
m_DrawMode: 0
|
||||||
|
m_Size: {x: 1, y: 1}
|
||||||
|
m_AdaptiveModeThreshold: 0.5
|
||||||
|
m_SpriteTileMode: 0
|
||||||
|
m_WasSpriteAssigned: 1
|
||||||
|
m_MaskInteraction: 0
|
||||||
|
m_SpriteSortPoint: 0
|
||||||
|
--- !u!1 &1744797149
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1744797150}
|
||||||
|
- component: {fileID: 1744797151}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Rumble
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &1744797150
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1744797149}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 781349954}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &1744797151
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1744797149}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 89c1239a77bb4cc43b1a1552d271ab99, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &2026065161
|
--- !u!1 &2026065161
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -677,6 +943,9 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
moveSpeed: 5
|
moveSpeed: 5
|
||||||
|
stepCooldown: 0.2
|
||||||
|
stepVibrationTime: 0.05
|
||||||
|
rumble: {fileID: 1744797149}
|
||||||
--- !u!4 &2026065165
|
--- !u!4 &2026065165
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -699,5 +968,7 @@ SceneRoots:
|
||||||
m_Roots:
|
m_Roots:
|
||||||
- {fileID: 63829549}
|
- {fileID: 63829549}
|
||||||
- {fileID: 2026065165}
|
- {fileID: 2026065165}
|
||||||
|
- {fileID: 107616020}
|
||||||
- {fileID: 646449338}
|
- {fileID: 646449338}
|
||||||
- {fileID: 1420709241}
|
- {fileID: 1420709241}
|
||||||
|
- {fileID: 781349954}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1b72f262654afae4f835fd9da6d63f8b
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
public class PS5Controller : MonoBehaviour
|
||||||
|
{
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Gamepad.all.Count; i++)
|
||||||
|
{
|
||||||
|
Debug.Log(Gamepad.all[i].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d79b9b67e3de5ba4590c4e63726f5c8b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,46 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
public class RumbleManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
private Gamepad pad1;
|
||||||
|
private Gamepad pad2;
|
||||||
|
|
||||||
|
private Coroutine stopRumbleAfterTimeCorutine;
|
||||||
|
|
||||||
|
|
||||||
|
public void RumblePulse1(float lowFrequency, float highFrequency, float duration)
|
||||||
|
{
|
||||||
|
pad1 = Gamepad.all[0];
|
||||||
|
if (pad1 != null)
|
||||||
|
{
|
||||||
|
pad1.SetMotorSpeeds(lowFrequency, highFrequency);
|
||||||
|
|
||||||
|
stopRumbleAfterTimeCorutine = StartCoroutine(stopRumble(duration, pad1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void RumblePulse2(float lowFrequency, float highFrequency, float duration)
|
||||||
|
{
|
||||||
|
pad2 = Gamepad.all[1];
|
||||||
|
if (pad2 != null)
|
||||||
|
{
|
||||||
|
pad2.SetMotorSpeeds(lowFrequency, highFrequency);
|
||||||
|
|
||||||
|
stopRumbleAfterTimeCorutine = StartCoroutine(stopRumble(duration, pad2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator stopRumble(float duration, Gamepad pad)
|
||||||
|
{
|
||||||
|
float elapsedTime = 0f;
|
||||||
|
while (elapsedTime < duration)
|
||||||
|
{
|
||||||
|
elapsedTime += Time.deltaTime;
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
pad.SetMotorSpeeds(0f, 0f);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 89c1239a77bb4cc43b1a1552d271ab99
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -1,25 +0,0 @@
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class PlayerMovement : MonoBehaviour
|
|
||||||
{
|
|
||||||
public float moveSpeed = 5f;
|
|
||||||
private Rigidbody2D rb;
|
|
||||||
private Vector2 movement;
|
|
||||||
|
|
||||||
private void Start()
|
|
||||||
{
|
|
||||||
rb = GetComponent<Rigidbody2D>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
movement.x = Input.GetAxisRaw("Horizontal");
|
|
||||||
movement.y = Input.GetAxisRaw("Vertical");
|
|
||||||
}
|
|
||||||
private void FixedUpdate()
|
|
||||||
{
|
|
||||||
rb.velocity = (movement * moveSpeed);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
public class PlayerMovement1 : MonoBehaviour
|
||||||
|
{
|
||||||
|
public float moveSpeed = 5f;
|
||||||
|
private Rigidbody2D rb;
|
||||||
|
private Vector2 movement;
|
||||||
|
private Gamepad playerController;
|
||||||
|
|
||||||
|
private bool right = false;
|
||||||
|
|
||||||
|
private bool vibrate = false;
|
||||||
|
[SerializeField] private float stepCooldown = 0.05f;
|
||||||
|
[SerializeField] private float stepVibrationTime = 0.05f;
|
||||||
|
|
||||||
|
[SerializeField] private GameObject rumble;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
rb = GetComponent<Rigidbody2D>();
|
||||||
|
|
||||||
|
playerController = Gamepad.all[0];
|
||||||
|
|
||||||
|
StartCoroutine(ToggleWithDelay());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
movement.x = playerController.leftStick.x.ReadValue();
|
||||||
|
movement.y = playerController.leftStick.y.ReadValue();
|
||||||
|
if (movement.x != 0 || movement.y != 0)
|
||||||
|
RumbleWalk();
|
||||||
|
}
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
rb.velocity = (movement * moveSpeed);
|
||||||
|
}
|
||||||
|
private void RumbleWalk()
|
||||||
|
{
|
||||||
|
if (vibrate)
|
||||||
|
{
|
||||||
|
if (right)
|
||||||
|
{
|
||||||
|
rumble.GetComponent<RumbleManager>().RumblePulse1(0.0f, 0.004f, stepVibrationTime);
|
||||||
|
right = false;
|
||||||
|
}
|
||||||
|
else if (!right)
|
||||||
|
{
|
||||||
|
rumble.GetComponent<RumbleManager>().RumblePulse1(0.004f, 0.0f, stepVibrationTime);
|
||||||
|
right = true;
|
||||||
|
}
|
||||||
|
vibrate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private IEnumerator ToggleWithDelay()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
vibrate = !vibrate;
|
||||||
|
yield return new WaitForSeconds(stepCooldown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
public class PlayerMovement2 : MonoBehaviour
|
||||||
|
{
|
||||||
|
public float moveSpeed = 5f;
|
||||||
|
private Rigidbody2D rb;
|
||||||
|
private Vector2 movement;
|
||||||
|
private Gamepad playerController;
|
||||||
|
|
||||||
|
private bool right = false;
|
||||||
|
|
||||||
|
private bool vibrate = false;
|
||||||
|
[SerializeField] private float stepCooldown = 0.05f;
|
||||||
|
[SerializeField] private float stepVibrationTime = 0.05f;
|
||||||
|
|
||||||
|
[SerializeField] private GameObject rumble;
|
||||||
|
|
||||||
|
private float cooldown;
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
rb = GetComponent<Rigidbody2D>();
|
||||||
|
|
||||||
|
playerController = Gamepad.all[1];
|
||||||
|
|
||||||
|
StartCoroutine(ToggleWithDelay());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
movement.x = playerController.leftStick.x.ReadValue();
|
||||||
|
movement.y = playerController.leftStick.y.ReadValue();
|
||||||
|
if (movement.x != 0 || movement.y != 0)
|
||||||
|
RumbleWalk();
|
||||||
|
}
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
rb.velocity = (movement * moveSpeed);
|
||||||
|
}
|
||||||
|
private void RumbleWalk()
|
||||||
|
{
|
||||||
|
if (vibrate)
|
||||||
|
{
|
||||||
|
if (right)
|
||||||
|
{
|
||||||
|
rumble.GetComponent<RumbleManager>().RumblePulse2(0.0f, 0.004f, stepVibrationTime);
|
||||||
|
right = false;
|
||||||
|
}
|
||||||
|
else if (!right)
|
||||||
|
{
|
||||||
|
rumble.GetComponent<RumbleManager>().RumblePulse2(0.004f, 0.0f, stepVibrationTime);
|
||||||
|
right = true;
|
||||||
|
}
|
||||||
|
vibrate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private IEnumerator ToggleWithDelay()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
vibrate = !vibrate;
|
||||||
|
yield return new WaitForSeconds(stepCooldown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e891644cda7544948af35b0d2f2c3be2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -4,6 +4,7 @@
|
||||||
"com.unity.feature.2d": "2.0.0",
|
"com.unity.feature.2d": "2.0.0",
|
||||||
"com.unity.ide.rider": "3.0.27",
|
"com.unity.ide.rider": "3.0.27",
|
||||||
"com.unity.ide.visualstudio": "2.0.22",
|
"com.unity.ide.visualstudio": "2.0.22",
|
||||||
|
"com.unity.inputsystem": "1.7.0",
|
||||||
"com.unity.render-pipelines.universal": "14.0.9",
|
"com.unity.render-pipelines.universal": "14.0.9",
|
||||||
"com.unity.test-framework": "1.1.33",
|
"com.unity.test-framework": "1.1.33",
|
||||||
"com.unity.textmeshpro": "3.0.6",
|
"com.unity.textmeshpro": "3.0.6",
|
||||||
|
|
|
@ -160,6 +160,15 @@
|
||||||
},
|
},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
|
"com.unity.inputsystem": {
|
||||||
|
"version": "1.7.0",
|
||||||
|
"depth": 0,
|
||||||
|
"source": "registry",
|
||||||
|
"dependencies": {
|
||||||
|
"com.unity.modules.uielements": "1.0.0"
|
||||||
|
},
|
||||||
|
"url": "https://packages.unity.com"
|
||||||
|
},
|
||||||
"com.unity.mathematics": {
|
"com.unity.mathematics": {
|
||||||
"version": "1.2.6",
|
"version": "1.2.6",
|
||||||
"depth": 1,
|
"depth": 1,
|
||||||
|
|
|
@ -664,7 +664,7 @@ PlayerSettings:
|
||||||
hmiLogStartupTiming: 0
|
hmiLogStartupTiming: 0
|
||||||
hmiCpuConfiguration:
|
hmiCpuConfiguration:
|
||||||
apiCompatibilityLevel: 6
|
apiCompatibilityLevel: 6
|
||||||
activeInputHandler: 0
|
activeInputHandler: 2
|
||||||
windowsGamepadBackendHint: 0
|
windowsGamepadBackendHint: 0
|
||||||
cloudProjectId:
|
cloudProjectId:
|
||||||
framebufferDepthMemorylessMode: 0
|
framebufferDepthMemorylessMode: 0
|
||||||
|
|
Loading…
Reference in New Issue