using System;
using UnityEngine;
using System.Collections;
public class carmove2 : MonoBehaviour {
public bool go;
private float posz;
// Use this for initialization
void Start () {
go = false;
}
// Update is called once per frame
void Update () {
posz = transform.position.z;
if (!go && posz >= 93.4f && posz <= 93.6f) {
// Что здесь?
} else {
transform.Translate(0, 0, 0.2f);
};
if (posz >= 130) {
Destroy(gameObject);
}
}
}
using UnityEngine;
using System.Collections;
public class lightmanager1 : MonoBehaviour {
private bool pressed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update() {
foreach (Touch touch in Input.touches) {
if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled) {
pressed = !pressed;
break;
}
}
// Может так?
this.GetComponent<carmove2>().go = pressed;
}
}
public class lightmanager2 : MonoBehaviour {
private bool pressed;
private carmove2 scr1;
// Use this for initialization
void Start () {
scr1 = new carmove2();
}
// Update is called once per frame
void Update() {
foreach (Touch touch in Input.touches) {
if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled) {
pressed = !pressed;
break;
}
}
// Или может так?
scr1.go = pressed;
}
}