I’m working on a little bow game.
It was easy to make some basic arrow physics, but I would like to show the player the motion path of the arrow, before the arrow is shot and I have absolutely no idea how to do that.
Does anybody have an idea how to do that?.
Thanks in advance
you want to render a line all you need to do is feed that line a series of vertices of points along the line.
So just calculate say the end point the mid point and a point between the beginning and mid and a point between the mid and end and you should have a good curve representing the line the arrow will travel.
this is a parabola : -x^2
in code that would be:
consider x to be the ‘distance’ traveled by the arrow
if you want to go higher, you will be doing the following 4-x^2, with 4 becoming the maximum height.
You can use something like the above to visualize what’s going on with your curve and formula and try to manipulate the values to see what you can come up with (and then translate it to code). (remember Mathf.pow is used to square things (to the 'pow’er of 2))
You could also try the TrailRenderer component:
TrailRenderer script reference
TrailRenderer Ref Manual
Not so cheap hint: Fire an invisible arrow with a TrailRenderer component to (seemingly) simulate the ‘actual’ arrow’s path.