Add camera movement

This commit is contained in:
Crizomb 2024-12-22 21:42:27 +01:00
parent 6a897fabfc
commit d4a32d9593
3 changed files with 199 additions and 3 deletions

View file

@ -175,6 +175,156 @@ Transform:
- {fileID: 8481046749175316991}
m_Father: {fileID: 543450653570552176}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &665745495
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 665745496}
- component: {fileID: 665745497}
m_Layer: 0
m_Name: GameManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &665745496
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 665745495}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -42.183693, y: 6.0864706, z: 48.780235}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &665745497
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 665745495}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Actions: {fileID: -944628639613478452, guid: 289c1b55c9541489481df5cc06664110, type: 3}
m_NotificationBehavior: 2
m_UIInputModule: {fileID: 0}
m_DeviceLostEvent:
m_PersistentCalls:
m_Calls: []
m_DeviceRegainedEvent:
m_PersistentCalls:
m_Calls: []
m_ControlsChangedEvent:
m_PersistentCalls:
m_Calls: []
m_ActionEvents:
- m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 942806718}
m_TargetAssemblyTypeName: CameraMouvement, Assembly-CSharp
m_MethodName: HandleCameraMovement
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_ActionId: 351f2ccd-1f9f-44bf-9bec-d62ac5c5f408
m_ActionName: 'Player/Move[/Keyboard/w,/Keyboard/upArrow,/Keyboard/s,/Keyboard/downArrow,/Keyboard/a,/Keyboard/leftArrow,/Keyboard/d,/Keyboard/rightArrow]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: 6b444451-8a00-4d00-a97e-f47457f736a8
m_ActionName: 'Player/Look[/Mouse/delta]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: 6c2ab1b8-8984-453a-af3d-a3c78ae1679a
m_ActionName: 'Player/Attack[/Mouse/leftButton,/Keyboard/enter]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: 852140f2-7766-474d-8707-702459ba45f3
m_ActionName: 'Player/Interact[/Keyboard/e]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: 27c5f898-bc57-4ee1-8800-db469aca5fe3
m_ActionName: 'Player/Crouch[/Keyboard/c]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: f1ba0d36-48eb-4cd5-b651-1c94a6531f70
m_ActionName: 'Player/Jump[/Keyboard/space]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: 2776c80d-3c14-4091-8c56-d04ced07a2b0
m_ActionName: 'Player/Previous[/Keyboard/1]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: b7230bb6-fc9b-4f52-8b25-f5e19cb2c2ba
m_ActionName: 'Player/Next[/Keyboard/2]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: 641cd816-40e6-41b4-8c3d-04687c349290
m_ActionName: 'Player/Sprint[/Keyboard/leftShift]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: c95b2375-e6d9-4b88-9c4c-c5e76515df4b
m_ActionName: 'UI/Navigate[/Keyboard/w,/Keyboard/upArrow,/Keyboard/s,/Keyboard/downArrow,/Keyboard/a,/Keyboard/leftArrow,/Keyboard/d,/Keyboard/rightArrow]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: 7607c7b6-cd76-4816-beef-bd0341cfe950
m_ActionName: 'UI/Submit[/Keyboard/enter]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: 15cef263-9014-4fd5-94d9-4e4a6234a6ef
m_ActionName: 'UI/Cancel[/Keyboard/escape]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: 32b35790-4ed0-4e9a-aa41-69ac6d629449
m_ActionName: 'UI/Point[/Mouse/position]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: 3c7022bf-7922-4f7c-a998-c437916075ad
m_ActionName: 'UI/Click[/Mouse/leftButton]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: 44b200b1-1557-4083-816c-b22cbdf77ddf
m_ActionName: 'UI/RightClick[/Mouse/rightButton]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: dad70c86-b58c-4b17-88ad-f5e53adf419e
m_ActionName: 'UI/MiddleClick[/Mouse/middleButton]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: 0489e84a-4833-4c40-bfae-cea84b696689
m_ActionName: 'UI/ScrollWheel[/Mouse/scroll]'
- m_PersistentCalls:
m_Calls: []
m_ActionId: 24908448-c609-4bc3-a128-ea258674378a
m_ActionName: UI/TrackedDevicePosition
- m_PersistentCalls:
m_Calls: []
m_ActionId: 9caa3d8a-6b2f-4e8e-8bad-6ede561bd9be
m_ActionName: UI/TrackedDeviceOrientation
m_NeverAutoSwitchControlSchemes: 0
m_DefaultControlScheme:
m_DefaultActionMap: Player
m_SplitScreenIndex: -1
m_Camera: {fileID: 0}
--- !u!1 &680117605
GameObject:
m_ObjectHideFlags: 0
@ -283,7 +433,7 @@ Transform:
m_GameObject: {fileID: 680117605}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -35.02, y: 4.22, z: 42.75}
m_LocalPosition: {x: -35.02, y: 8.49, z: 42.75}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -373,6 +523,7 @@ GameObject:
- component: {fileID: 942806717}
- component: {fileID: 942806716}
- component: {fileID: 942806715}
- component: {fileID: 942806718}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
@ -447,13 +598,26 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 942806714}
serializedVersion: 2
m_LocalRotation: {x: -0.18064015, y: -0.5735358, z: 0.13145474, w: -0.78812784}
m_LocalPosition: {x: -44.221096, y: 8.898422, z: 39.77604}
m_LocalRotation: {x: 0.1732985, y: 0.6265177, z: -0.14558041, w: 0.7458214}
m_LocalPosition: {x: -66.04596, y: 17.987251, z: 44.5997}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &942806718
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 942806714}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9c8ad113b549ec9a0ac0bedf3875c19e, type: 3}
m_Name:
m_EditorClassIdentifier:
moveSpeed: 20
--- !u!1 &1479652158
GameObject:
m_ObjectHideFlags: 0
@ -3282,6 +3446,7 @@ Transform:
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 665745496}
- {fileID: 942806717}
- {fileID: 1479652160}
- {fileID: 543450653570552176}

View file

@ -0,0 +1,29 @@
using UnityEngine;
using UnityEngine.InputSystem;
public class CameraMouvement : MonoBehaviour
{
[SerializeField] private float moveSpeed = 5f;
private Vector2 _moveInput;
public void HandleCameraMovement(InputAction.CallbackContext context)
{
_moveInput = Vector2.zero;
if (context.phase == InputActionPhase.Performed)
{
_moveInput = context.ReadValue<Vector2>();
}
}
// 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()
{
var mouvement = moveSpeed * Time.deltaTime * (new Vector3(_moveInput.y, 0, -_moveInput.x));
transform.Translate(mouvement, Space.World);
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9c8ad113b549ec9a0ac0bedf3875c19e