Короче, не работает как надо.
Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class Batterfly : MonoBehaviour {
// скорость падения, передвижения, поворота
public float fallspeed, movespeed, turnspeed;
// вспомогательные переменные контроллера и трансформа
CharacterController controller;
Transform thistransform;
void Start () {
controller = this.GetComponent<CharacterController>();
thistransform = transform;
}
void FixedUpdate () {
// начинаем полет
controller.Move(transform.forward * movespeed * Time.deltaTime * Input.GetAxis("Vertical") + Vector3.down * fallspeed * Time.deltaTime);
// занимаемся расчетом поворота игрока
Quaternion root = Quaternion.AngleAxis(turnspeed * Time.deltaTime * Input.GetAxis("Horizontal"), Vector3.up);
thistransform.rotation *= root;
// поднимаем высоту полета
if (Input.GetKey(KeyCode.Space)) {
thistransform.position = new Vector3(thistransform.position.x, thistransform.position.y * fallspeed * Time.deltaTime, thistransform.position.z);
}
}
}
using System.Collections;
public class Batterfly : MonoBehaviour {
// скорость падения, передвижения, поворота
public float fallspeed, movespeed, turnspeed;
// вспомогательные переменные контроллера и трансформа
CharacterController controller;
Transform thistransform;
void Start () {
controller = this.GetComponent<CharacterController>();
thistransform = transform;
}
void FixedUpdate () {
// начинаем полет
controller.Move(transform.forward * movespeed * Time.deltaTime * Input.GetAxis("Vertical") + Vector3.down * fallspeed * Time.deltaTime);
// занимаемся расчетом поворота игрока
Quaternion root = Quaternion.AngleAxis(turnspeed * Time.deltaTime * Input.GetAxis("Horizontal"), Vector3.up);
thistransform.rotation *= root;
// поднимаем высоту полета
if (Input.GetKey(KeyCode.Space)) {
thistransform.position = new Vector3(thistransform.position.x, thistransform.position.y * fallspeed * Time.deltaTime, thistransform.position.z);
}
}
}