Skip to main content
added 98 characters in body
Source Link
Bálint
  • 15.1k
  • 2
  • 38
  • 57

so i been trying to find a way to shoot projectiles along a curve path . and i found this tutorial on youtube which was really good. here (https://www.youtube.com/watch?v=IvT8hjy6q4otutorial on youtube which was really good).

i also uploaded the project in case you wanted to check it out. here (http://www.mediafire.com/file/z5zfqbcnpznnbsh/arc+luncher.unitypackagehere)

but there is problem with this script .if i move the target object somewhere above the starting point the curved path will be diapered and i get couple of errors.in fact when ever the path is about to become a straight line the errors will pop up . here is the screenshot of errors (https://ibb.co/vZ5JTZ2) and

enter image description here and here is a gif file to show when the problem shows up (http://www.mediafire.com/view/55phgr5qrhy8fk1/record.gif)

enter image description here

and finally here is the code responsible for calculating the curve path a lunching projectiles.

so i been trying to find a way to shoot projectiles along a curve path . and i found this tutorial on youtube which was really good. here (https://www.youtube.com/watch?v=IvT8hjy6q4o)

i also uploaded the project in case you wanted to check it out. here (http://www.mediafire.com/file/z5zfqbcnpznnbsh/arc+luncher.unitypackage)

but there is problem with this script .if i move the target object somewhere above the starting point the curved path will be diapered and i get couple of errors.in fact when ever the path is about to become a straight line the errors will pop up . here is the screenshot of errors (https://ibb.co/vZ5JTZ2) and here is a gif file to show when the problem shows up (http://www.mediafire.com/view/55phgr5qrhy8fk1/record.gif) and finally here is the code responsible for calculating the curve path a lunching projectiles.

so i been trying to find a way to shoot projectiles along a curve path . and i found this tutorial on youtube which was really good.

i also uploaded the project in case you wanted to check it out. here

but there is problem with this script .if i move the target object somewhere above the starting point the curved path will be diapered and i get couple of errors.in fact when ever the path is about to become a straight line the errors will pop up . here is the screenshot of errors

enter image description here and here is a gif file to show when the problem shows up

enter image description here

and finally here is the code responsible for calculating the curve path a lunching projectiles.

deleted 13 characters in body
Source Link
h00man13
  • 69
  • 2
  • 8

but there is problem with this script .if i move the target object somewhere above the starting point the curved path will be diapered and i get couple of errors.in fact when ever the path is about to become a straight line the errors will pop up . here is the screenshot of errors (https://ibb.co/vZ5JTZ2) and here is a gif file to show when the problem shows up (http://www.mediafire.com/view/6pmdk6gh1yzejyr/GIF_20190530_122436.gifhttp://www.mediafire.com/view/55phgr5qrhy8fk1/record.gif) and finally here is the code responsible for calculating the curve path a lunching projectiles.

but there is problem with this script .if i move the target object somewhere above the starting point the curved path will be diapered and i get couple of errors.in fact when ever the path is about to become a straight line the errors will pop up . here is the screenshot of errors (https://ibb.co/vZ5JTZ2) and here is a gif file to show when the problem shows up (http://www.mediafire.com/view/6pmdk6gh1yzejyr/GIF_20190530_122436.gif) and finally here is the code responsible for calculating the curve path a lunching projectiles.

but there is problem with this script .if i move the target object somewhere above the starting point the curved path will be diapered and i get couple of errors.in fact when ever the path is about to become a straight line the errors will pop up . here is the screenshot of errors (https://ibb.co/vZ5JTZ2) and here is a gif file to show when the problem shows up (http://www.mediafire.com/view/55phgr5qrhy8fk1/record.gif) and finally here is the code responsible for calculating the curve path a lunching projectiles.

Source Link
h00man13
  • 69
  • 2
  • 8

help with shooting projectile along a curve path

so i been trying to find a way to shoot projectiles along a curve path . and i found this tutorial on youtube which was really good. here (https://www.youtube.com/watch?v=IvT8hjy6q4o)

i also uploaded the project in case you wanted to check it out. here (http://www.mediafire.com/file/z5zfqbcnpznnbsh/arc+luncher.unitypackage)

but there is problem with this script .if i move the target object somewhere above the starting point the curved path will be diapered and i get couple of errors.in fact when ever the path is about to become a straight line the errors will pop up . here is the screenshot of errors (https://ibb.co/vZ5JTZ2) and here is a gif file to show when the problem shows up (http://www.mediafire.com/view/6pmdk6gh1yzejyr/GIF_20190530_122436.gif) and finally here is the code responsible for calculating the curve path a lunching projectiles.

 public Transform startPoint; public Transform target; public int resolution = 30; public float curveHight = 25; public float gravity = -18; public Rigidbody bullet; public LineRenderer lineRenderer; void Start() { } void Update() { DrawPath(); if (Input.GetKeyDown(KeyCode.Space)) { Launch(); } } void Launch() { Rigidbody clone = Instantiate(bullet, startPoint.position, Quaternion.identity); Physics.gravity = Vector3.up * gravity; clone.velocity = CalculateLaunchData().initialVelocity; } LaunchData CalculateLaunchData() { float displacementY = target.position.y - startPoint.position.y; Vector3 displacementXZ = new Vector3(target.position.x - startPoint.position.x, 0, target.position.z - startPoint.position.z); float time = Mathf.Sqrt(-2 * curveHight / gravity) + Mathf.Sqrt(2 * (displacementY - curveHight) / gravity); Vector3 velocityY = Vector3.up * Mathf.Sqrt(-2 * gravity * curveHight); Vector3 velocityXZ = displacementXZ / time; return new LaunchData(velocityXZ + velocityY * -Mathf.Sign(gravity), time); } void DrawPath() { LaunchData launchData = CalculateLaunchData(); Vector3 previousDrawPoint = startPoint.position; for (int i = 1; i <= resolution; i++) { float simulationTime = i / (float)resolution * launchData.timeToTarget; Vector3 displacement = launchData.initialVelocity * simulationTime + Vector3.up * gravity * simulationTime * simulationTime / 2f; Vector3 drawPoint = startPoint.position + displacement; Debug.DrawLine(previousDrawPoint, drawPoint, Color.green); previousDrawPoint = drawPoint; lineRenderer.positionCount = resolution; lineRenderer.SetPosition(i - 1, drawPoint); } } struct LaunchData { public readonly Vector3 initialVelocity; public readonly float timeToTarget; public LaunchData(Vector3 initialVelocity, float timeToTarget) { this.initialVelocity = initialVelocity; this.timeToTarget = timeToTarget; } }} 

so,any idea what might be causing the the problem?