Browse Source

Added input system

master
Joshua Reason 4 years ago
parent
commit
56b73634c5
5 changed files with 171 additions and 5 deletions
  1. +8
    -0
      Assets/Input.meta
  2. +143
    -0
      Assets/Input/HerdInput.inputactions
  3. +14
    -0
      Assets/Input/HerdInput.inputactions.meta
  4. +4
    -4
      Assets/Scripts/Input/HerdController.cs
  5. +2
    -1
      Assets/WorldAssets/Prefabs/Cube.prefab

+ 8
- 0
Assets/Input.meta View File

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

+ 143
- 0
Assets/Input/HerdInput.inputactions View File

@ -0,0 +1,143 @@
{
"name": "HerdInput",
"maps": [
{
"name": "Overworld",
"id": "c89e2228-b7f5-4b32-ac4e-fbea6cb10475",
"actions": [
{
"name": "Movement",
"type": "Value",
"id": "99cdc6da-5df1-4136-b79d-1c3760ff7733",
"expectedControlType": "Vector2",
"processors": "",
"interactions": ""
}
],
"bindings": [
{
"name": "WASD",
"id": "585768f2-f8f3-49a1-92ce-749719640d21",
"path": "2DVector",
"interactions": "",
"processors": "",
"groups": "",
"action": "Movement",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "up",
"id": "4ffbcb13-b94c-4f7f-9ede-adc65315d423",
"path": "<Keyboard>/w",
"interactions": "",
"processors": "",
"groups": "",
"action": "Movement",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "down",
"id": "f0c4e586-5052-40ea-8727-6ffbcf1906f4",
"path": "<Keyboard>/s",
"interactions": "",
"processors": "",
"groups": "",
"action": "Movement",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "left",
"id": "cb18a7d8-37af-489c-a9e8-f10a7d549297",
"path": "<Keyboard>/a",
"interactions": "",
"processors": "",
"groups": "",
"action": "Movement",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "right",
"id": "79ea85ef-a2c7-4a70-8a62-c915f57351e7",
"path": "<Keyboard>/d",
"interactions": "",
"processors": "",
"groups": "",
"action": "Movement",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "Arrow",
"id": "be124a39-a025-4851-8072-acf105391a89",
"path": "2DVector",
"interactions": "",
"processors": "",
"groups": "",
"action": "Movement",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "up",
"id": "6c34a5fc-b8b1-4004-ac64-8b0d90f7ecd1",
"path": "<Keyboard>/upArrow",
"interactions": "",
"processors": "",
"groups": "",
"action": "Movement",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "down",
"id": "542d8dc4-c0a9-484f-aac9-da4d5feda688",
"path": "<Keyboard>/downArrow",
"interactions": "",
"processors": "",
"groups": "",
"action": "Movement",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "left",
"id": "acf7c952-58bd-480f-9f8a-06af08a6d5bb",
"path": "<Keyboard>/leftArrow",
"interactions": "",
"processors": "",
"groups": "",
"action": "Movement",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "right",
"id": "3940709f-2905-4a5d-be3e-588e416ba132",
"path": "<Keyboard>/rightArrow",
"interactions": "",
"processors": "",
"groups": "",
"action": "Movement",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "df6fcd3e-9fe7-4f14-8b39-5db8f9ec190a",
"path": "<Gamepad>/leftStick",
"interactions": "",
"processors": "",
"groups": "",
"action": "Movement",
"isComposite": false,
"isPartOfComposite": false
}
]
}
],
"controlSchemes": []
}

+ 14
- 0
Assets/Input/HerdInput.inputactions.meta View File

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

+ 4
- 4
Assets/Scripts/Input/HerdController.cs View File

@ -16,7 +16,7 @@ public class HerdController : MonoBehaviour
[SerializeField]
private Transform SpawnPoint;
private List<GameObject> Herd;
private List<PlayerController> Herd;
@ -24,7 +24,7 @@ public class HerdController : MonoBehaviour
private void OnMovement(InputValue value)
{
Vector2 input = value.Get<Vector2>();
Herd.ForEach(p => p.SetMovement(input));
}
@ -39,7 +39,7 @@ public class HerdController : MonoBehaviour
if (Herd != null)
Herd.ForEach(p => Destroy(p));
Herd = new List<GameObject>();
Herd = new List<PlayerController>();
for (int i = 0; i < HerdCount; i++)
{
@ -59,7 +59,7 @@ public class HerdController : MonoBehaviour
{
GameObject newObject = Instantiate(Prefab, position, rotation, transform);
Herd.Add(newObject);
Herd.Add(newObject.GetComponent<PlayerController>());
break;

+ 2
- 1
Assets/WorldAssets/Prefabs/Cube.prefab View File

@ -66,9 +66,10 @@ MonoBehaviour:
m_GameObject: {fileID: 588491153375435794}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 58f8f74b224d33d458c143811ba0a32a, type: 3}
m_Script: {fileID: 11500000, guid: 3a0ed68fb4a52474dbfbbcfb40e2f68d, type: 3}
m_Name:
m_EditorClassIdentifier:
walkSpeed: 10
--- !u!1 &4098178456956087476
GameObject:
m_ObjectHideFlags: 0

Loading…
Cancel
Save