Этот скрипт говорит о том, что при столкновении объекта с объектом, он дает 8 пуль и исчезает.
Вопрос, как сделать так, чтобы после исчезновения объекта через определённый промежуток времени объект снова появился?
Синтаксис:
Используется javascript
static var gun_ammo = 0;
function OnControllerColliderHit(hit:ControllerColliderHit)
{
if(hit.gameObject.tag == "ammo")
{
Destroy(hit.gameObject);
gun_ammo +=8;
print("You have "+gun_ammo+" ammo");
GameObject.Find("g_Count").guiText.text = ""+gun_ammo;
}
if(Input.GetButtonDown("Fire1"))
{
if(Collisions.gun_ammo > 0)
{
Collisions.gun_ammo --;
print("You now have "+Collisions.gun_ammo+" ammo");
GameObject.Find("g_Count").guiText.text = ""+gun_ammo;
}
}
}
var rayCastLength = 5;
function Update ()
{
var hit : RaycastHit;
if(Physics.Raycast(transform.position, transform.forward, hit, rayCastLength))
{
if(hit.collider.gameObject.tag == "door")
{
hit.collider.gameObject.animation.Play("door_open");
}
}
}
function OnControllerColliderHit(hit:ControllerColliderHit)
{
if(hit.gameObject.tag == "ammo")
{
Destroy(hit.gameObject);
gun_ammo +=8;
print("You have "+gun_ammo+" ammo");
GameObject.Find("g_Count").guiText.text = ""+gun_ammo;
}
if(Input.GetButtonDown("Fire1"))
{
if(Collisions.gun_ammo > 0)
{
Collisions.gun_ammo --;
print("You now have "+Collisions.gun_ammo+" ammo");
GameObject.Find("g_Count").guiText.text = ""+gun_ammo;
}
}
}
var rayCastLength = 5;
function Update ()
{
var hit : RaycastHit;
if(Physics.Raycast(transform.position, transform.forward, hit, rayCastLength))
{
if(hit.collider.gameObject.tag == "door")
{
hit.collider.gameObject.animation.Play("door_open");
}
}
}