本文主要是介绍Unity实战案例 2D小游戏HappyGlass(画笔摇晃效果),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
本案例素材和教程都来自Siki学院,十分感谢教程中的老师
本文仅作学习笔记分享交流,不作任何商业用途
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Pencil : MonoBehaviour
{//摆动速度public float pencilSpeed;//摆动频率public float pencilSquency;//初始角度private float StartZ;// Start is called before the first frame updatevoid Start(){StartZ = transform.localEulerAngles.z;}// Update is called once per framevoid Update(){transform.localEulerAngles = new Vector3(0, 0, StartZ+Mathf.Sin(Time.time*pencilSquency) *pencilSpeed);}
}
这篇关于Unity实战案例 2D小游戏HappyGlass(画笔摇晃效果)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!