Quantcast
Channel: Questions in topic: "gun"
Viewing all articles
Browse latest Browse all 592

my bullet holes get stuck in mid air

$
0
0
hello i have a problem with the script i made and its actually 2 problems well for one when i shoot my gun the bullet holes get stuck in mid air and the second problem is is that when i shoot my gun the bullets shoot straight but they shoot out turn sideways does anyone know how to fix this problem. heres my script 1 of them are bullets movement and the other one is bullet shoot. shoot: using UnityEngine; using System.Collections; public class shoot2 : MonoBehaviour { public GameObject bullet; public GameObject bulletHole; public float delayTime = 0.5f; private float counter = 0; void FixedUpdate () { if(Input.GetKey(KeyCode.Mouse0) && Time.time >= counter) { Instantiate(bullet, transform.position, transform.rotation); audio.Play(); counter = Time.time + delayTime; RaycastHit hit; Ray ray = new Ray(transform.position, transform.forward); if(Physics.Raycast(ray, out hit, 100f)) { Instantiate(bulletHole, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)); } } } } bullet move: using UnityEngine; using System.Collections; public class MoveBullet : MonoBehaviour { public float speed = 1f; void Start () { } void Update () { transform.Translate(0, 0, speed); } }

Viewing all articles
Browse latest Browse all 592

Trending Articles