24836人加入学习
(77人评价)
Unity零基础入门 - 见缝插针(Unity2017)
价格 免费

控制针移动到就位位置

添加脚本Pin控制针的运动

[展开全文]

RotateSelf 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RotateSelf : MonoBehaviour
{
    public float speed = 90;

    // Update is called once per frame
    void Update()
    {
        transform.Rotate(new Vector3(0, 0, -speed * Time.deltaTime));// 控制小球旋转,
    }
}


GameObject

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameManager : MonoBehaviour
{
    private Transform startPoint;
    private Transform spawnPoint;
    public GameObject pinPrefab;
    // Start is called before the first frame update
    void Start()
    {
        startPoint = GameObject.Find("StartPoint").transform;
        spawnPoint = GameObject.Find("SpawnPoint").transform;
        SpawnPin();
    }
    void SpawnPin()//对针的实例化
    {
        GameObject.Instantiate(pinPrefab, spawnPoint.position, pinPrefab.transform.rotation);
    }
}

 

[展开全文]

授课教师

SiKi学院老师

课程特色

下载资料(1)
视频(12)