|
I have a crosshair on the main camara and a fire function on my gun (zap) but when I fire the projectiles (standard Roll A Ball)it fires to right of the camera and right from where the crosshair points. Crosshair function java (under Main Camera) var crosshairTexture : Texture2D; var position : Rect; static var OriginalOn = true; function Update() // Start will only get the screen size once. it will not refresh it. the turn around is to use function Update() instead. { position = Rect((Screen.width - crosshairTexture.width) / 2, (Screen.height - crosshairTexture.height) /2, crosshairTexture.width, crosshairTexture.height); } function OnGUI() { if(OriginalOn == true) { GUI.DrawTexture(position, crosshairTexture); } } Fire function C# (under the gun) using UnityEngine; using System.Collections; public class fire : MonoBehaviour { public GameObject projectile; public float fireRate = 0.5F; private float nextFire = 0.0F; }
(comments are locked)
|

Please format your code correctly by highlighting the entire code and pressing the 101010 button.