using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using ZenFulcrum.Track;
public class CarMove : MonoBehaviour {
public Button button;
public Button bt1;
public bool flag;
void Start () {
button.onClick.AddListener(CarMoveStart);
}
void Update () {
if(flag )
{
GetComponent<TrackCart>().CurrentTrack.brakes.maxForce = 10;
}
}
public void CarMoveStart()
{
bt1.gameObject.SetActive(false);
flag = false;
GetComponent<TrackCart>().CurrentTrack.acceleration.targetSpeed = 20;
GetComponent<TrackCart>().CurrentTrack.acceleration.maxForce = 5;
GetComponent<TrackCart>().CurrentTrack.brakes.maxForce = 0;
button.gameObject.transform.Find("Text").GetComponent<Text>().text = "刹车";
button.onClick.RemoveAllListeners();
button.onClick.AddListener(CarMoveStop);
}
public void CarMoveStop()
{
GetComponent<TrackCart>().CurrentTrack.brakes.targetSpeed = 0;
GetComponent<TrackCart>().CurrentTrack.brakes.maxForce = 10;
GetComponent<TrackCart>().CurrentTrack.acceleration.maxForce = 0;
button.gameObject.transform.Find("Text").GetComponent<Text>().text = "启动";
button.onClick.RemoveAllListeners();
button.onClick.AddListener(CarMoveStart);
flag = true;
}
}
Track插件里的加速和刹车
最新推荐文章于 2019-09-27 19:32:41 发布