Hello there,
I’m learning unity with “Unity Game Development Essentials”.
Now I have a task to write a script (using examples) to make myself a trigger, which opens door .
For people, who wants to help me, I made screenshots of 10 pages of the book, where the task is:
First
Second
Third
Fourth
Fifth
Sixth
Seventh
Eight
Nineth
Tenth
The actual problem with Unity
Tried a lot of variants, actually, because, I don’t know nothing in the scripting.
My script:
private var doorIsOpen : boolean = false;
private var doorTimer : float = 0.0;
private var currentDoor : GameObject;
var doorOpenTime : float = 3.0;
var doorSlideOpen : AudioClip;
var doorSlideShut : AudioClip;
function Start ()
{
}
function Update()
{
if(doorIsOpen)
{
doorTimer += Time.deltaTime;
if(doorTimer > 3)
{
Door(doorSlideShut, false, "doorshut", currentDoor);
doorTimer = 0.0;
}
}
}
function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.GameObject.tag == "currentDoor" doorIsOpen == false)
{
curentDoor = hit.GameObject;
Door(doorSlideOpen, true, "doorOpen", currentDoor);
Door.animation.Play(doorOpen);
}
}
function doorOpen()
{
audio.PlayOneShot(doorSlideOpen);
doorIsOpen = true;
var myOutpost : GameObject = GameObject.Find("outpost");
myOutpost.animation.Play("doorOpen");
}
function doorShut()
{
audio.PlayOneShot(doorSlideShut);
doorIsOpen = false;
var myOutpost : GameObject = GameObject.Find("outpost");
myOutpost.animation.Play("doorShut");
}
function Door(aClip : AudioClip, openCheck : boolean, animName :
String, thisDoor : GameObject)
{
audio.PlayOneShot(aClip);
doorIsOpen = openCheck;
Door.transform.parent.animation.Play(animName);
}
@script RequireComponent(AudioSource);
Who can, please help ;(