Суть скрипта: Когда игрок подходит к шкафу, при нажатии на E, проигрывается анимация открытия дверей(У шкафа находиться триггер)
Синтаксис:
Используется javascript
var player : GameObject;
var animObject : Animation;
var anim : AnimationClip;
private var enter : boolean;
function OnGUI(){
if(enter){
Style = GUI.skin.label;
Style.normal.textColor = Color.black;
Style.fontSize = 26;
GUI.Label(new Rect(Screen.width/2 - 150, Screen.height - 100, 500, 50), "Нажмите E чтобы открыть шкаф");
}
}
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Player") {
enter = true;
}
}
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == "Player") {
enter = false;
}
}
function OnTriggerStay (other : Collider) {
if (Input.GetKeyDown("e")) {
animObject.GetComponent.<Animation>().clip = anim;
animObject.Play();
}
}
var animObject : Animation;
var anim : AnimationClip;
private var enter : boolean;
function OnGUI(){
if(enter){
Style = GUI.skin.label;
Style.normal.textColor = Color.black;
Style.fontSize = 26;
GUI.Label(new Rect(Screen.width/2 - 150, Screen.height - 100, 500, 50), "Нажмите E чтобы открыть шкаф");
}
}
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Player") {
enter = true;
}
}
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == "Player") {
enter = false;
}
}
function OnTriggerStay (other : Collider) {
if (Input.GetKeyDown("e")) {
animObject.GetComponent.<Animation>().clip = anim;
animObject.Play();
}
}