Hi
I try this but it's no work
I have Unity 4.1.5f1
using UnityEngine;
using System.Collections;
using System;
//se met automatiquement sur les vl
public class TrajetVl : MonoBehaviour {
public GameObject target_Path;
public float time = 29.8f;
public float fraction;
public Transform[] tabt;
private bool running = false;
private bool paused = false;
void Start () {
SetPath(target_Path);
}
void SetPath (GameObject pathObject) {
int id = 0;
tabt = new Transform[pathObject.transform.childCount];
foreach (Transform child in pathObject.transform) {
tabt[id++] = child.transform;
}
StartCoroutine("WalkThePath");
}
IEnumerator WalkThePath () {
bool paused = false;
bool running = true;
while (running) {
transform.position = iTween.PointOnPath(tabt, fraction);
if (!paused)
fraction += Time.deltaTime / time;
if (fraction > 1.0f)
fraction = 0.0f;
}
transform.LookAt(iTween.PointOnPath(tabt, fraction + 0.0000000001f));
yield return null;
}
}
/*
* public var target_Path1 : GameObject; // donner le path de MAYA
public var time = 29.8; // donner le temps de parcours, variable modifiable par autre script avec ''static '' public staticvar time = 10;
//private var InitTime = time; ?? // variable qui permet de revenir à la vitesse initiale EGALE à ''time''
public var fraction = 0.0; // variable de WalkOnPath qui donne la position sur le path en %
public var VentreegiratoireSeuil = 70.0; // vitesse fixe pour toutes les entrées
public var VsortiegiratoireSeuil = 30.0; // vitesse fixe pour toutes le sorties, mettre un cube vert un peu après dans le maquette
private var tabt : Transform[];
private var running = false;
private var paused = false;
function SetPath (pathObject : GameObject){
var id : int = 0;
tabt =null;
tabt = new Transform[pathObject.transform.childCount];
for(var child: Transform in pathObject.transform) {
tabt[id++] = child.transform;
}
WalkThePath();
}
function WalkThePath() {
paused = false;
running = true;
fraction = 0.1; // 1er départ de la vidéo debut du parcours si 0.8 alors à 80% (fraction = Pourcentage; ??)
while (running) {
transform.position = iTween.PointOnPath(tabt, fraction);
if (!paused)
fraction += Time.deltaTime / time;
if (fraction > 1.0) fraction = 0.0; // si 0.0 alors aller simple, le trajet reprend au 1° point
// si 1 trajet repart dans l'uatre sens
var futurePos = iTween.PointOnPath(tabt, fraction + 0.0000000001);
transform.LookAt(futurePos);
yield;
}
}
function Start()
{
SetPath(target_Path1);
}
function Awake ()
{
target_Path1 = GameObject.Find("Repere_Trajet_E");
}*/
↧