Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class bullet : MonoBehaviour {
- Vector3 right_me;
- RaycastHit hit;
- Rigidbody rb_me;
- [Range(0f,5000f)]
- public float speed;
- // Use this for initialization
- void Start () {
- right_me = transform.TransformDirection (Vector3.right);
- rb_me = GetComponent<Rigidbody> ();
- }
- void Update(){
- rb_me.velocity = new Vector3 (1 * speed , 0 ,0);
- //rb_me.AddForce (Vector3.right * speed * Time.deltaTime);
- }
- // Update is called once per frame
- void FixedUpdate () {
- Debug.DrawRay (transform.position, right_me, Color.red);
- if (Physics.Raycast(transform.position,Vector3.right,out hit,1)){
- if(hit.collider.tag == "Wall"){
- Debug.Log ("Acertou a Parede");
- Destroy (gameObject);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement