1
\$\begingroup\$

I am not sure how to go about what might be a simple task. I want directional arrow sprites to move along a curved path in 2d to show the player when to go.

I can use DoTween to create a path. But not sure if I should Instantiate a load of sprites(arrow) and move them along. Its seems wasteful.

enter image description here

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Did you consider doing this with a LineRenderer and a scrolling tiling texture? \$\endgroup\$
    – DMGregory
    Commented Sep 15, 2019 at 0:35
  • \$\begingroup\$ Not I didn't actually. I looked it up and I don't see any examples unfortunately. \$\endgroup\$ Commented Sep 15, 2019 at 1:04
  • \$\begingroup\$ Thank you @DMGregory for that suggestion. I did more research and was able to get this working. If you want to add your suggestion as an answer I would be happy to mark it as the correct one. \$\endgroup\$ Commented Sep 15, 2019 at 10:37
  • \$\begingroup\$ If you have a working solution to your problem, then you'd be in an even better position to write it up as an answer — with screenshots and details of how you set it up to serve your needs. It's 100% OK to answer your own questions here. :) \$\endgroup\$
    – DMGregory
    Commented Sep 15, 2019 at 11:31
  • \$\begingroup\$ I think it would be great if you added your own answer to this question, I could learn from it ;) \$\endgroup\$
    – Millard
    Commented Sep 15, 2019 at 19:33

1 Answer 1

0
\$\begingroup\$

Here is the following code I added to the LineRenderer to scroll the tiles texture.

public class LineArrow : MonoBehaviour
{
    public float scrollSpeed = 1f;
    public Renderer _renderer;
    // Start is called before the first frame update
    void Start()
    {
        _renderer = GetComponent<LineRenderer>();
    }

    // Update is called once per frame
    void Update()
    {
        float vOffset = Time.time * scrollSpeed;
        _renderer.material.SetTextureOffset("_MainTex", new Vector2(vOffset, 0));
    }
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .