没有合适的资源?快使用搜索试试~ 我知道了~
首页Unity实现见缝插针小游戏
Unity实现见缝插针小游戏
532 浏览量
更新于2023-05-27
评论
收藏 79KB PDF 举报
主要为大家详细介绍了Unity实现见缝插针小游戏,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
资源详情
资源评论
资源推荐

Unity实现见缝插针小游戏实现见缝插针小游戏
主要为大家详细介绍了Unity实现见缝插针小游戏,文中示例代码介绍的非常详细,具有一定的参考价值,感兴
趣的小伙伴们可以参考一下
本文实例为大家分享了Unity实现见缝插针游戏的具体代码,供大家参考,具体内容如下
控制小球旋转
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateSelf : MonoBehaviour {
//每秒旋转90度
public float speed = 90;
// Update is called once per frame
void Update () {
//绕Z轴顺针旋转
transform.Rotate(new Vector3(0, 0, -speed * Time.deltaTime));
}
}
针头碰撞检测
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PinHead : MonoBehaviour {
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag == "PinHead")
{
GameObject.Find("GameManager").GetComponent<GameManager>().GameOver();
}
}
}
控制针的运动位置
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pin : MonoBehaviour {
public float speed = 5;
private bool isFly = false;
private bool isReach = false;
private Transform startPoint;
private Vector3 targetCirclePos;
private Transform circle;
// Use this for initialization


















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0