控制针移动到就位位置
添加脚本Pin控制针的运动
控制针移动到就位位置
添加脚本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);
}
}