目录:
1.正弦曲线:
private float get_Sin_Z_Value(float x)
{
float ZQ; //周期
float inner = (2 * (float)Mathf.PI) / ZQ; //角速度
float ya = (float)Mathf.Sin(inner * x);
float maall = swing_len * 0.5f; //swing_len是振幅
float middle = maall - swing_len / 2;
return (middle + maall * ya);
}
2.DOTween 插值渐变
3.untiy 对手柄的适配
4. 获取每一个按键的名称
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
public class PlayerJoystickClass : MonoBehaviour {
private string currentButton;//当前按下的按键
// Use this for initialization
void Start () {
}
string[] names = {"LL", "LR", "RL", "RR", "DX", "DY", "HX", "HY"};
// Update is called once per frame
void Update () {
var values = Enum.GetValues(typeof(KeyCode));//存储所有的按键
for (int x = 0; x < values.Length; x++)
{
if (Input.GetKeyDown((KeyCode)values.GetValue(x)))
{
currentButton = values.GetValue(x).ToString();//遍历并获取当前按下的按键
}
}
/*for (int i = 0; i < names.Length; i ++)
{
if(Input.GetAxis(names[i]) > 0 && Input.GetAxis(names[i]) < 1)
{
currentButton = (names[i] + "正向");
}
if (Input.GetAxis(names[i]) < 0 && Input.GetAxis(names[i]) > -1)
{
currentButton = (names[i] + "负向");
}
}*/
}
void OnGUI()
{
GUI.TextArea(new Rect(0, 0, 250, 40), "Current Button : " + currentButton);//使用GUI在屏幕上面实时打印当前按下的按键
}
}
5. 设置坐标
transform代表世界坐标,unity中显示的是局部坐标。
处理方式有两种:
a.将物体移动根目录层获得其坐标。
b.使用其父物体的世界坐标来进行设置。
6. 动画操作
坐标由于需要适配不同的分辨率,所以最好使用DOLocal..相关的函数操作。
public AnimationCurve anim_curve的变量用于动画曲线的设置。
7. buff系统
缠绕了两个周的工作,投入的时间很多,但是效果不是很明显,不过教训是挺多的,确实也是第一次完整的写一个这么大的系统了,找个时间专门写一下来为以后做忠告了。