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

RayCast Line Not Rotating with Gun?

$
0
0
Hey gang Have my Recast machine gun looking beautiful here only problem is "Forward " Dose not rotate when I rotate my Gun and keeps facing the One-direction... public float FireRate = 0.1f; private float NextFire; public float ShootRange = 60; public float Damage = 1.0f; public float Shotduration = 0.2f; private LineRenderer BulletTracer; private bool ReadytoFire; void Start(){ BulletTracer = GetComponent (); } void Update(){ if (Input.GetButton ("Fire1") && Time.time > NextFire) { NextFire = Time.time + FireRate; StartCoroutine(ShotEffect()); RaycastHit hit; BulletTracer.SetPosition (0, transform.position); if (Physics.Raycast (transform.position, transform.forward, out hit, ShootRange)) { BulletTracer.SetPosition (1, hit.point); } else{ BulletTracer.SetPosition(1, new Vector3(0, 0, ShootRange)); } if(hit.collider.gameObject.tag == "Enemyy"){ hit.collider.SendMessage("GunHit", Damage, SendMessageOptions.DontRequireReceiver ); } } } private IEnumerator ShotEffect(){ BulletTracer.enabled = true; yield return Shotduration; BulletTracer.enabled = false; } }

Viewing all articles
Browse latest Browse all 592

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>