Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

I want to repeat my ground when my player hit the second part of the ground.

Discussion in 'General Discussion' started by shez561, Apr 27, 2020.

  1. shez561

    shez561

    Joined:
    Sep 19, 2019
    Posts:
    20
    Hi,

    I am working on my first game which is an endless car racing and since I am new I face difficulty in writing the perfect codes.

    As per the attachment, I need help to repeat my ground which consist of 2 platforms and every time when my player crosses the first platform I want the same to start over at the end of second platform.
    Actually I have pretty much done that and the platform repeating itself but I actually want my player to repeat that platform for me rather than platform repeating itself.

    Please help me in writing the correct code that when my player hit the second platform the first platform should repeat again after second platform.

    Scene.png

    Script.png
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,337
    Put platform into prefab, and instantiate/spawn another one before player reaches the end of it.
     
  3. shez561

    shez561

    Joined:
    Sep 19, 2019
    Posts:
    20
    Thanks for the idea @neginfinity , it really worked.