Hello everyone! I just started unity with my oculus rift a few days now , im just looking for scripts around and edit or write a few lines my self so far until one day i manage to write my own scripts
, I have found and edit the code below but i cant make the coroutine work, game is crashing.
Any help ?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SecondBulletShots : MonoBehaviour {
public GameObject Bullet_Emitter;
public GameObject Bullet;
public float Bullet_Forward_Force;
//SOUND
public AudioClip clip;
public AudioSource audioSource;
public Transform gunBarrelTransform;
//reloading waiting time
public float ReloadingTime;
//ammo
private int ammo = 13;
void Start ()
{
audioSource = GetComponent ();
audioSource.clip = clip;
}
void Update ()
{
if (OVRInput.GetDown (OVRInput.Button.PrimaryIndexTrigger))
{
if (ammo > 1) {
//DONISH JOYSTICK 1 DE3I CONTROLLER 0 ARISTERO
OVRHaptics.Channels[0].Preempt(new OVRHapticsClip(clip));
// HXOS
audioSource.Play ();
//The Bullet instantiation
GameObject Temporary_Bullet_Handler;
Temporary_Bullet_Handler = Instantiate(Bullet,Bullet_Emitter.transform.position,Bullet_Emitter.transform.rotation) as GameObject;
//FIX
//Temporary_Bullet_Handler.transform.Rotate(Vector3.left * 90);
//Retrieve the Rigidbody component from the instantiated Bullet and control it.
Rigidbody Temporary_RigidBody;
Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent();
//Tell the bullet to be âpushedâ forward by an amount set by Bullet_Forward_Force.
Temporary_RigidBody.AddForce(transform.up * Bullet_Forward_Force);
//Basic Clean Up
Destroy(Temporary_Bullet_Handler, 3.0f);
//AMMO REDUCTION
ammoâ;
if (ammo == 1) {
StartCoroutine(reloads ());
}
}
}
}
IEnumerator reloads ()
{
while (true) {
if(OVRInput.GetDown(OVRInput.Button.Three))
{
yield return new WaitForSeconds (ReloadingTime);
ammo = 13;
}
}
}
}