/
UserInput.cs
44 lines (36 loc) · 1.23 KB
/
UserInput.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class UserInput : MonoBehaviour
{
public float Dup;
public float Dright;
public float Dmag;
public Vector3 Dvec; // vector 3 para el giro del personaje segun la entrada
public float Jup;
public float Jright;
public bool run;
public bool defense;
public bool jump;
protected bool lastJump;
public bool attack;
protected bool lastAtttack;
public bool lockon;
public bool roll;
[Header("======== Otros ========")]
public bool inputEnable = true; // varibale para comprobar si puede recibir señal o no
// variables para smoothdamp
protected float targetDup;
protected float targetDright;
protected float velocityDup;
protected float velocityDright;
// metodos convierte rectangulo en circulo
//http://squircular.blogspot.com/2015/09/mapping-circle-to-square.html
protected Vector2 SquareToCircle(Vector2 inputArea)
{
Vector2 output = Vector2.zero;
output.x = inputArea.x * Mathf.Sqrt(1 - (inputArea.y * inputArea.y) / 2.0f);
output.y = inputArea.y * Mathf.Sqrt(1 - (inputArea.x * inputArea.x) / 2.0f);
return output;
}
}