Question by
unity_YYoxtjdH92iNIg · Feb 04, 2020 at 04:06 PM ·
gameobjecttriggercoroutinemove
Gameobject doesnt move after build
my gameobject move when triggered in editor..but after build when i play builded one gameobject doesnt move..here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cikiskapitrigger : MonoBehaviour
{
public float hiz = 1f;
public Transform doorthatmove;
public float timer;
public float sayac;
public AudioClip calinacakses;
public float ses;
AudioSource sesyeni;
public bool alreadyplayed = false;
void Start()
{
sesyeni = GetComponent<AudioSource>();
}
void OnTriggerEnter(Collider other)
{
if (!alreadyplayed&&other.gameObject.CompareTag("oyuncu"))
{
sesyeni.PlayOneShot(calinacakses, ses);
alreadyplayed = true;
StartCoroutine(kapiacil());
}
}
IEnumerator kapiacil()
{
while (doorthatmove.gameObject.transform.position.y < 12)
{
doorthatmove.gameObject.transform.Translate(0, hiz * Time.deltaTime, 0);
yield return null;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Moving GameObject slowly OnTriggerEnter 1 Answer
What is the best way to script a trigger that moves a object from point a to point b in C# (unity 5) 0 Answers
Transform search function only sporadically works?! 1 Answer
Two colliders that trigger different things in the same object-hierarchy 0 Answers
GameObject doesn't move 1 Answer