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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Swipe Through

Discussion in 'Scripting' started by gamecreator333, Jun 7, 2015.

  1. gamecreator333

    gamecreator333

    Joined:
    May 4, 2015
    Posts:
    21
    Have a question.
    I am trying to make a script that has 2 objects. And every swipe i want then switched up.​
     
    Last edited: Jun 30, 2015
  2. chubbspet

    chubbspet

    Joined:
    Feb 18, 2010
    Posts:
    1,220
    do you have any script yet, because it is a lot of code you are asking for.
     
  3. gamecreator333

    gamecreator333

    Joined:
    May 4, 2015
    Posts:
    21
    I don't have any code yet. But I am just looking for any help to show me in the write direction.
     
  4. gamecreator333

    gamecreator333

    Joined:
    May 4, 2015
    Posts:
    21
    Anyone have any suggestions?
     
  5. lordconstant

    lordconstant

    Joined:
    Jul 4, 2013
    Posts:
    389
    Have a list/array of locations that you want the cubes to be at then if you have a reference to each cube you can just ive them between the locations.
     
  6. Zaladur

    Zaladur

    Joined:
    Oct 20, 2012
    Posts:
    392
    Tons of implementations possible.

    From a pure data sense, one basic way would be

    Code (csharp):
    1.  
    2. //go left
    3. for (int i=0;i<ItemList.Count; i++){
    4.     ItemList[i] = ItemList[(i+1)%ItemList.Count];
    5. }
    6.  
    7. //go right
    8. for (int i=0;i<ItemList.Count; i++){
    9.     ItemList[i] = ItemList[(i-1)%ItemList.Count];
    10. }
    You can use List.RemoveAt and List.Insert at the start and end of the list as well.
     
  7. gamecreator333

    gamecreator333

    Joined:
    May 4, 2015
    Posts:
    21
    Thanks for the reply.
    Can you explain how a lost works and how I could use it.
     
  8. gamecreator333

    gamecreator333

    Joined:
    May 4, 2015
    Posts:
    21
    Thanks for the reply. I will test it out.
    Do you know how I would be able to add a slide animation so it doesn't just look like the items are just changing.
     
  9. gamecreator333

    gamecreator333

    Joined:
    May 4, 2015
    Posts:
    21
     
    Last edited: Jun 18, 2015