im trying to make a 2.5d style mobile style game. my character works on my PC put not everything works for mobile; the firing to be exact. i understand that i need to make a separate function but every time i do it stops working…could a more experienced person tell me what i need to fix…i supply don’t know what to do.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class fireBullet : MonoBehaviour {
public float timeBetweenBullets = 0.15f;
public GameObject projectile;
//bullet info
public Slider playerAmmoSlider;
public int maxRounds;
public int startingRounds;
int remainingRounds;
float nextBullet;
//graphic info
public Sprite weaponSprite;
public Image weaponImage;
// Use this for initialization
void Awake () {
nextBullet = 0f;
remainingRounds = startingRounds;
playerAmmoSlider.maxValue = maxRounds;
playerAmmoSlider.value = remainingRounds;
}
// Update is called once per frame
void Update () {
playerController myPlayer = transform.root.GetComponent ();
if (Input.GetAxisRaw (“Fire 1”) > 0 && nextBullet < Time.time && remainingRounds>0) {
nextBullet = Time.time + timeBetweenBullets;
Vector3 rot;
if (myPlayer.GetFacing () == -1f){
rot = new Vector3 (0, -90, 0);
} else rot = new Vector3 (0, 90, 0);
Instantiate (projectile, transform.position, Quaternion.Euler (rot));
remainingRounds -=0;
playerAmmoSlider.value = remainingRounds;
}
}
public void reload(){
remainingRounds = maxRounds;
playerAmmoSlider.value = remainingRounds;
}
public void initializeWeapon(){
nextBullet = 0;
playerAmmoSlider.maxValue = maxRounds;
playerAmmoSlider.value = remainingRounds;
}
}