Advertisement
WPDeveloper

Untitled

Jan 16th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class bullet : MonoBehaviour {
  5.  
  6.     Vector3 right_me;
  7.     RaycastHit hit;
  8.     Rigidbody rb_me;
  9.     [Range(0f,5000f)]
  10.     public float speed;
  11.  
  12.  
  13.     // Use this for initialization
  14.     void Start () {
  15.         right_me = transform.TransformDirection (Vector3.right);
  16.         rb_me = GetComponent<Rigidbody> ();
  17.    
  18.     }
  19.  
  20.     void Update(){
  21.         rb_me.velocity = new Vector3 (1 * speed , 0 ,0);
  22.         //rb_me.AddForce (Vector3.right * speed * Time.deltaTime);
  23.  
  24.     }
  25.    
  26.     // Update is called once per frame
  27.     void FixedUpdate () {
  28.         Debug.DrawRay (transform.position, right_me, Color.red);
  29.  
  30.         if (Physics.Raycast(transform.position,Vector3.right,out hit,1)){
  31.             if(hit.collider.tag == "Wall"){
  32.                 Debug.Log ("Acertou a Parede");
  33.                 Destroy (gameObject);
  34.             }
  35.  
  36.         }
  37.    
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement