Use line renderer to create an arrow

I am trying to attach an arrow that changes direction and color to a ball in my minigolf game, using line renderer. I tried to give the shape of an arrow but I can’t do it. I would like to write a script that allow the arrow to rotate in the direction chosen by the user with some buttons and to change color based on the force chosen, but I can’t even start by creating the arrow. Should I change method? Should I use something else other than line renderer?
Thanks in advance

You don’t mention what’s the problem preventing you from drawing an arrow. Just placing the points in the line to form an arrow shape should be enough?

If you’re unsure about the math required to do this, I’d recommend looking up basic vector math, specifically addition, normalization, dot and cross product. Those should be enough for your purpose.

2 Likes

if the arrow is always same size and length,
probably easier to use pre-made 2D or 3D arrow sprite/model. (and can adjust tint color in the material)

do you have some inspiration/reference image from other minigolf games?
some of them have animated arrows too.

Sorry but I am very new at using Unity and I am learning from various tutorials… do you mean that I have to use these operations in a script attached to the object with the line renderer? I have no idea how to do that, but maybe I have to read again the line renderer manual

I would like it to change also in dimensions, something similar to infiniteMinigolf for example

scaling could work,
or having the arrow head as separate object, so can scale line length only.

screenshot from that game,
could also have that kind of custom shader that fills or reveals the gradient.

Correct, you use these operations to calculate the points that describe an arrow shape, then pass these to the line renderer.

Note that using a LineRenderer is only good if you want the arrow to be an outline, otherwise you’d want to use another method. Here’s a video tutorial on how to draw an arrow using a mesh:

https://www.youtube.com/watch?v=8lXDLy24rJw

1 Like

Thank you very much!!