Début contrôle des deux mains du tavernier
This commit is contained in:
parent
af7c65e845
commit
c3c2f47b45
2 changed files with 23 additions and 7 deletions
|
@ -4,12 +4,13 @@ using UnityEngine;
|
||||||
|
|
||||||
public class Tavernkeeper_controller : MonoBehaviour
|
public class Tavernkeeper_controller : MonoBehaviour
|
||||||
{
|
{
|
||||||
public float speed = 5.0f;
|
public float mvt_speed = 5.0f; //Movement speed
|
||||||
|
|
||||||
Rigidbody2D rigidbody2d;
|
Rigidbody2D rigidbody2d;
|
||||||
// Last user inputs
|
// Last user inputs
|
||||||
float horizontal;
|
float horizontal;
|
||||||
float vertical;
|
float vertical;
|
||||||
|
float hands;
|
||||||
|
|
||||||
Animator animator;
|
Animator animator;
|
||||||
Vector2 lookDirection = new Vector2(1,0);
|
Vector2 lookDirection = new Vector2(1,0);
|
||||||
|
@ -40,6 +41,21 @@ public class Tavernkeeper_controller : MonoBehaviour
|
||||||
animator.SetFloat("Look X", lookDirection.x);
|
animator.SetFloat("Look X", lookDirection.x);
|
||||||
animator.SetFloat("Look Y", lookDirection.y);
|
animator.SetFloat("Look Y", lookDirection.y);
|
||||||
animator.SetFloat("Speed", move.magnitude);
|
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
|
// Update used by the Physics engine
|
||||||
|
@ -47,8 +63,8 @@ public class Tavernkeeper_controller : MonoBehaviour
|
||||||
{
|
{
|
||||||
//Movement of a physic object
|
//Movement of a physic object
|
||||||
Vector2 position = rigidbody2d.position;
|
Vector2 position = rigidbody2d.position;
|
||||||
position.x = position.x + speed * horizontal * Time.deltaTime;
|
position.x = position.x + mvt_speed * horizontal * Time.deltaTime;
|
||||||
position.y = position.y + speed * vertical * Time.deltaTime;
|
position.y = position.y + mvt_speed * vertical * Time.deltaTime;
|
||||||
|
|
||||||
rigidbody2d.MovePosition(position); //Movement processed by the phyisc engine for Collision, etc.
|
rigidbody2d.MovePosition(position); //Movement processed by the phyisc engine for Collision, etc.
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,12 +38,12 @@ InputManager:
|
||||||
axis: 0
|
axis: 0
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
m_Name: Fire1
|
m_Name: Hand
|
||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton: h
|
||||||
positiveButton: left ctrl
|
positiveButton: g
|
||||||
altNegativeButton:
|
altNegativeButton: mouse 1
|
||||||
altPositiveButton: mouse 0
|
altPositiveButton: mouse 0
|
||||||
gravity: 1000
|
gravity: 1000
|
||||||
dead: 0.001
|
dead: 0.001
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue