333GameStudio

Battery

Feb 20th, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Charge : float = 2;
  2.  public var Bar : UnityEngine.UI.Image;  
  3.  public var fillAmount: float;
  4. var Fuel : float = 0.00025;
  5.  var fireLight : Light;
  6.  
  7.  
  8. function Update() {
  9. var up = transform.TransformDirection(Vector3.forward);
  10.    var hit : RaycastHit;    
  11.    Debug.DrawRay(transform.position, up * 5, Color.red);
  12.        
  13.        if(Physics.Raycast(transform.position, up, hit, 5)){
  14.        if(hit.collider.gameObject.tag == "Battery"){
  15.  
  16.         fireLight.GetComponent.<Light>().intensity += Charge;
  17.         Bar.fillAmount = (Bar.fillAmount + Fuel);
  18.        
  19.       Destroy(hit.transform.gameObject);
  20.  
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment