void Update()
{
// D/N
this.actual_time = (this.actual_time + Time.deltaTime) % this.cycleTime;
// intensity setting
this.sun.intensity = -4 * (this.actual_time % this.cycleTime / this.cycleTime * 2) * (this.actual_time % this.cycleTime / this.cycleTime * 2) + 4 * (this.actual_time % this.cycleTime / this.cycleTime * 2);
// position du soleil
this.sun.transform.position = Orbit(this.actual_time);
this.sun.transform.LookAt(gameObject.transform);
// Sound
this.cdMusic -= Time.deltaTime;
if (this.cdMusic <= 0)
{
this.source.PlayOneShot(this.clipMenu, 1f);
this.cdMusic = 112f;
}
if (this.onChar)
{
if (Vector3.Distance(this.cam.transform.position, this.camAim.transform.position) > this.acceptance * this.speed / 1.2f )
{
this.cam.transform.rotation = Quaternion.Lerp(this.cam.transform.rotation, this.camAim.transform.rotation, 0.08f);
cam.transform.Translate((this.camAim.transform.position - cam.transform.position).normalized * this.speed, Space.World);
}
else
{
this.speed = 0.05f;
Quaternion lastrot = this.cam.transform.rotation;
this.cam.transform.LookAt(this.camAim.transform.GetChild(0));
Quaternion newrot = this.cam.transform.rotation;
this.cam.transform.rotation = Quaternion.Lerp(lastrot, newrot, 0.1f);
}
}
else if (this.goingback)
{
this.speed = 1.2f;
if (Vector3.Distance(this.cam.transform.position, this.backpos) > this.acceptance)
{
cam.transform.Translate((this.backpos - cam.transform.position).normalized * 1.2f, Space.World);
this.cam.transform.rotation = Quaternion.Lerp(this.cam.transform.rotation, this.backrot, 0.1f);
}
else
this.goingback = false;
}
else
{
// Camera
cam.transform.Translate(Vector3.forward * this.camSpeed);
//choose the rot;
Quaternion lastrot = this.cam.transform.rotation;
this.cam.transform.LookAt(this.step.transform);
Quaternion newrot = this.cam.transform.rotation;
this.cam.transform.rotation = Quaternion.Lerp(lastrot, newrot, 0.01f);
if (Vector3.Distance(this.cam.transform.position, this.step.transform.position) <= this.acceptance)
{
this.step = this.step.GetComponent<FSPath>().NextStep;
if (this.step.GetComponent<FSPath>() == null)
this.step = this.fistStep;
}
this.backpos = this.cam.gameObject.transform.position;
this.backrot = this.cam.gameObject.transform.rotation;
}
}