Quantcast
Channel: Questions in topic: "curved path"
Viewing all articles
Browse latest Browse all 116

I need to make a bullet prefab follow a set path(bezier angle) on an invisible line renderer

$
0
0
i have a mortor tower that will shoot a bullet in a curve, and to do this i am trying to make it follow a bezier curve drawn by a line renderer, but it is either falling off the map, or is going to the default object position. can anyone help me private Transform target; public GameObject explosionEffect; public GameObject impactEffect; public GameObject Turret; private Vector3[] emptyPositions; [HideInInspector]public float stunAmount; float stunFloat; public float bulletSpeed = 70f; public void Seek(Transform _target) { target = _target; } private void Update() { if (target == null) { Destroy(gameObject); return; } if (Turret == null) { Destroy(gameObject); return; } Vector3 dir = target.position - transform.position; float distanceThisFrame = bulletSpeed * Time.deltaTime; if (dir.magnitude <= distanceThisFrame) { HitTarget(); return; } if (Turret.GetComponent().useBullet) { transform.Translate(dir.normalized * distanceThisFrame, Space.World); } if (Turret.GetComponent().useMortar) { emptyPositions = new Vector3[Turret.GetComponent().curvedRenderer.positionCount]; emptyPositions = Turret.GetComponent().curvePositions; for (int i = 0; i < Turret.GetComponent().curvedRenderer.positionCount; i++) { transform.localPosition = (emptyPositions[i].normalized * bulletSpeed * Time.deltaTime); } } transform.LookAt(target); }

Viewing all articles
Browse latest Browse all 116

Trending Articles



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