Basic player movement

This commit is contained in:
Gerard Gascón 2023-08-08 01:50:44 +02:00
parent 9fdca82032
commit 32f5ed6299
36 changed files with 10406 additions and 466 deletions

267
Assets/Input/PlayerInput.cs Normal file
View file

@ -0,0 +1,267 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
// version 1.4.4
// from Assets/Input/PlayerInput.inputactions
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
public partial class @PlayerInput : IInputActionCollection2, IDisposable
{
public InputActionAsset asset { get; }
public @PlayerInput()
{
asset = InputActionAsset.FromJson(@"{
""name"": ""PlayerInput"",
""maps"": [
{
""name"": ""Gameplay"",
""id"": ""261560c8-9a4d-4cea-b5a9-6e7adac31f81"",
""actions"": [
{
""name"": ""Horizontal"",
""type"": ""Value"",
""id"": ""efa90e33-19be-4bb4-9ee7-85bc0e1f05bc"",
""expectedControlType"": ""Axis"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": true
},
{
""name"": ""Jump"",
""type"": ""Button"",
""id"": ""b7f369dd-397a-4bd9-94ab-049c118d538b"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Fire"",
""type"": ""Button"",
""id"": ""deaa9679-d40d-4dfd-9d34-cfe4b4e1acd1"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
{
""name"": ""Keyboard"",
""id"": ""a9dc1319-a68a-4db6-ab5b-44fbbaeca9eb"",
""path"": ""1DAxis"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Horizontal"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""negative"",
""id"": ""fb71e261-cef6-497e-b45e-8f5305fdd4f1"",
""path"": ""<Keyboard>/a"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Horizontal"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""positive"",
""id"": ""54c22c3b-b31d-4b99-af69-b921ec47e1bb"",
""path"": ""<Keyboard>/d"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Horizontal"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""Arrows"",
""id"": ""fa5d8e07-c176-4c0a-9fdd-ce86268cb17b"",
""path"": ""1DAxis"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Horizontal"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""negative"",
""id"": ""4d4b9350-8d5b-4d38-a12f-842b08701614"",
""path"": ""<Keyboard>/leftArrow"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Horizontal"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""positive"",
""id"": ""08fedb93-15e4-4668-8202-4a1e3b8a21a0"",
""path"": ""<Keyboard>/rightArrow"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Horizontal"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": """",
""id"": ""18c5423c-91fa-4fb5-9a08-118962502a61"",
""path"": ""<Keyboard>/space"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Jump"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""1624d14f-f9f6-4eac-962e-a3f9ad31592a"",
""path"": ""<Mouse>/leftButton"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Fire"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
],
""controlSchemes"": []
}");
// Gameplay
m_Gameplay = asset.FindActionMap("Gameplay", throwIfNotFound: true);
m_Gameplay_Horizontal = m_Gameplay.FindAction("Horizontal", throwIfNotFound: true);
m_Gameplay_Jump = m_Gameplay.FindAction("Jump", throwIfNotFound: true);
m_Gameplay_Fire = m_Gameplay.FindAction("Fire", throwIfNotFound: true);
}
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
public ReadOnlyArray<InputDevice>? devices
{
get => asset.devices;
set => asset.devices = value;
}
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
public IEnumerator<InputAction> GetEnumerator()
{
return asset.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Enable()
{
asset.Enable();
}
public void Disable()
{
asset.Disable();
}
public IEnumerable<InputBinding> bindings => asset.bindings;
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
{
return asset.FindAction(actionNameOrId, throwIfNotFound);
}
public int FindBinding(InputBinding bindingMask, out InputAction action)
{
return asset.FindBinding(bindingMask, out action);
}
// Gameplay
private readonly InputActionMap m_Gameplay;
private IGameplayActions m_GameplayActionsCallbackInterface;
private readonly InputAction m_Gameplay_Horizontal;
private readonly InputAction m_Gameplay_Jump;
private readonly InputAction m_Gameplay_Fire;
public struct GameplayActions
{
private @PlayerInput m_Wrapper;
public GameplayActions(@PlayerInput wrapper) { m_Wrapper = wrapper; }
public InputAction @Horizontal => m_Wrapper.m_Gameplay_Horizontal;
public InputAction @Jump => m_Wrapper.m_Gameplay_Jump;
public InputAction @Fire => m_Wrapper.m_Gameplay_Fire;
public InputActionMap Get() { return m_Wrapper.m_Gameplay; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(GameplayActions set) { return set.Get(); }
public void SetCallbacks(IGameplayActions instance)
{
if (m_Wrapper.m_GameplayActionsCallbackInterface != null)
{
@Horizontal.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnHorizontal;
@Horizontal.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnHorizontal;
@Horizontal.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnHorizontal;
@Jump.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Jump.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Jump.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@Fire.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnFire;
@Fire.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnFire;
@Fire.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnFire;
}
m_Wrapper.m_GameplayActionsCallbackInterface = instance;
if (instance != null)
{
@Horizontal.started += instance.OnHorizontal;
@Horizontal.performed += instance.OnHorizontal;
@Horizontal.canceled += instance.OnHorizontal;
@Jump.started += instance.OnJump;
@Jump.performed += instance.OnJump;
@Jump.canceled += instance.OnJump;
@Fire.started += instance.OnFire;
@Fire.performed += instance.OnFire;
@Fire.canceled += instance.OnFire;
}
}
}
public GameplayActions @Gameplay => new GameplayActions(this);
public interface IGameplayActions
{
void OnHorizontal(InputAction.CallbackContext context);
void OnJump(InputAction.CallbackContext context);
void OnFire(InputAction.CallbackContext context);
}
}

View file

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

View file

@ -0,0 +1,129 @@
{
"name": "PlayerInput",
"maps": [
{
"name": "Gameplay",
"id": "261560c8-9a4d-4cea-b5a9-6e7adac31f81",
"actions": [
{
"name": "Horizontal",
"type": "Value",
"id": "efa90e33-19be-4bb4-9ee7-85bc0e1f05bc",
"expectedControlType": "Axis",
"processors": "",
"interactions": "",
"initialStateCheck": true
},
{
"name": "Jump",
"type": "Button",
"id": "b7f369dd-397a-4bd9-94ab-049c118d538b",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Fire",
"type": "Button",
"id": "deaa9679-d40d-4dfd-9d34-cfe4b4e1acd1",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
{
"name": "Keyboard",
"id": "a9dc1319-a68a-4db6-ab5b-44fbbaeca9eb",
"path": "1DAxis",
"interactions": "",
"processors": "",
"groups": "",
"action": "Horizontal",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "negative",
"id": "fb71e261-cef6-497e-b45e-8f5305fdd4f1",
"path": "<Keyboard>/a",
"interactions": "",
"processors": "",
"groups": "",
"action": "Horizontal",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "positive",
"id": "54c22c3b-b31d-4b99-af69-b921ec47e1bb",
"path": "<Keyboard>/d",
"interactions": "",
"processors": "",
"groups": "",
"action": "Horizontal",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "Arrows",
"id": "fa5d8e07-c176-4c0a-9fdd-ce86268cb17b",
"path": "1DAxis",
"interactions": "",
"processors": "",
"groups": "",
"action": "Horizontal",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "negative",
"id": "4d4b9350-8d5b-4d38-a12f-842b08701614",
"path": "<Keyboard>/leftArrow",
"interactions": "",
"processors": "",
"groups": "",
"action": "Horizontal",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "positive",
"id": "08fedb93-15e4-4668-8202-4a1e3b8a21a0",
"path": "<Keyboard>/rightArrow",
"interactions": "",
"processors": "",
"groups": "",
"action": "Horizontal",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "18c5423c-91fa-4fb5-9a08-118962502a61",
"path": "<Keyboard>/space",
"interactions": "",
"processors": "",
"groups": "",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "1624d14f-f9f6-4eac-962e-a3f9ad31592a",
"path": "<Mouse>/leftButton",
"interactions": "",
"processors": "",
"groups": "",
"action": "Fire",
"isComposite": false,
"isPartOfComposite": false
}
]
}
],
"controlSchemes": []
}

View file

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