From c3c2f47b45e5badba7ac691347c36272ef135c98 Mon Sep 17 00:00:00 2001 From: Antoine H Date: Wed, 2 Dec 2020 10:40:27 +0100 Subject: [PATCH] =?UTF-8?q?D=C3=A9but=20contr=C3=B4le=20des=20deux=20mains?= =?UTF-8?q?=20du=20tavernier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Tavernkeeper_controller.cs | 22 +++++++++++++++++++--- ProjectSettings/InputManager.asset | 8 ++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/Tavernkeeper_controller.cs b/Assets/Scripts/Tavernkeeper_controller.cs index b2f2073..ed1aa0b 100644 --- a/Assets/Scripts/Tavernkeeper_controller.cs +++ b/Assets/Scripts/Tavernkeeper_controller.cs @@ -4,12 +4,13 @@ using UnityEngine; public class Tavernkeeper_controller : MonoBehaviour { - public float speed = 5.0f; + public float mvt_speed = 5.0f; //Movement speed Rigidbody2D rigidbody2d; // Last user inputs float horizontal; float vertical; + float hands; Animator animator; Vector2 lookDirection = new Vector2(1,0); @@ -40,6 +41,21 @@ public class Tavernkeeper_controller : MonoBehaviour animator.SetFloat("Look X", lookDirection.x); animator.SetFloat("Look Y", lookDirection.y); animator.SetFloat("Speed", move.magnitude); + + + hands = Input.GetAxis("Hand"); + // Debug.Log(hands); + if(!Mathf.Approximately(hands, 0.0f)) + { + if(hands>0) + { + Debug.Log("Left hand"); + } + else + { + Debug.Log("Right hand"); + } + } } // Update used by the Physics engine @@ -47,8 +63,8 @@ public class Tavernkeeper_controller : MonoBehaviour { //Movement of a physic object Vector2 position = rigidbody2d.position; - position.x = position.x + speed * horizontal * Time.deltaTime; - position.y = position.y + speed * vertical * Time.deltaTime; + position.x = position.x + mvt_speed * horizontal * Time.deltaTime; + position.y = position.y + mvt_speed * vertical * Time.deltaTime; rigidbody2d.MovePosition(position); //Movement processed by the phyisc engine for Collision, etc. } diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index 17c8f53..f608900 100644 --- a/ProjectSettings/InputManager.asset +++ b/ProjectSettings/InputManager.asset @@ -38,12 +38,12 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Fire1 + m_Name: Hand descriptiveName: descriptiveNegativeName: - negativeButton: - positiveButton: left ctrl - altNegativeButton: + negativeButton: h + positiveButton: g + altNegativeButton: mouse 1 altPositiveButton: mouse 0 gravity: 1000 dead: 0.001