Exemplo n.º 1
0
	// Update is called once per frame
	void Update () {
		
		if(instantiated){

			float temppos = instance.position.x + walkingspeed;
			instance.position = new Vector3(temppos, instance.position.y, instance.position.z);
			
			////Debug.Log ("ska ha flyttat sig framåt här");
			
			if(Mathf.Abs(spawnposition.x - instance.position.x)> pathlength){
				Destroy(instance.gameObject); //Vet inte om detta duger
				//PrefabUtility.DisconnectPrefabInstance(prefab);
				instantiated = false;
			}

			if(Mathf.Abs(spawnposition.x - instance.position.x)> pathlength - 3){

				hedvigani.startfadingaway();
			}

			if(hedvigani.gone && hasplayedfade == false){
				//musicRef.Enable(false);//HÄR SKA BAKGRUNDSMUSIKEN INTE SPELAS

				soundsource.clip = fadesound;
				soundsource.Play();
				hasplayedfade = true;
				past = gameObject.GetComponent<Traveltothepast>();
				past.timeTraveltoPast();
			} 
		}
	}
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (instantiated)
        {
            float temppos = instance.position.x + walkingspeed;
            instance.position = new Vector3(temppos, instance.position.y, instance.position.z);

            ////Debug.Log ("ska ha flyttat sig framåt här");

            if (Mathf.Abs(spawnposition.x - instance.position.x) > pathlength)
            {
                Destroy(instance.gameObject);                 //Vet inte om detta duger
                //PrefabUtility.DisconnectPrefabInstance(prefab);
                instantiated = false;
            }

            if (Mathf.Abs(spawnposition.x - instance.position.x) > pathlength - 3)
            {
                hedvigani.startfadingaway();
            }

            if (hedvigani.gone && hasplayedfade == false)
            {
                //musicRef.Enable(false);//HÄR SKA BAKGRUNDSMUSIKEN INTE SPELAS

                soundsource.clip = fadesound;
                soundsource.Play();
                hasplayedfade = true;
                past          = gameObject.GetComponent <Traveltothepast>();
                past.timeTraveltoPast();
            }
        }
    }