Search Unity

Is this even possible in Unity 2D?

Discussion in '2D' started by unity_94d33m, Sep 12, 2018.

  1. unity_94d33m

    unity_94d33m

    Joined:
    Sep 11, 2018
    Posts:
    20
    So basically I have a 2D texture track on a quad mesh which will infinitely scroll down and repeat. But I want to add point lights on the marks of the tracks and make it move WITH the marks as it goes down and repeat just like the tracks. Is this possible ?


    https://imgur.com/a/ZrsUW42

    The code to move the track:

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class TrackMove : MonoBehaviour {
    4.  
    5.     public float speed;
    6.     Vector2 offset;
    7.  
    8.  
    9.     void Start () {
    10.        
    11.     }
    12.    
    13.    
    14.     void Update () {
    15.         offset = new Vector2(0, Time.time * speed);
    16.  
    17.         GetComponent<Renderer>().material.mainTextureOffset = offset;
    18.     }
    19. }
     
  2. chatrat12

    chatrat12

    Joined:
    Jan 21, 2015
    Posts:
    122
    Yeah, it can be done. You'll just need a pool of point lights and you'll configure them based on how far apart the marks are, how many there are, and the current offset of your background.