3D Infinite Runner Game Tutorial – Unity3D (C#)

3D Infinite Runner Game – Unity3D (C#)


Play Demo

We have 2 choice to move character in an infinite runner game: move character or move ground. First one, you can move ground continuously in a negative direction to character and move right or left your character. I will explain the second one in this tutorial that a stable ground and a moving character.

For a brief description, we will create a plane as road, we will create some spheres to create coins and to make character move(it will follow the stable spheres and we will get a moving action) with Lerp method.

At first, create a Directional Light and a A plane with size (0.5, 1, 10). Create a sphere named P1 at the begining of plane( 0, 2, -5). This sphere is our start point. Now duplicate it, rename it as  P2 and replace it to (0, 2, -4.5). Character will move from P1 to P2, from P2 to P3, from P3 to P4 etc. So, create and place 20 spheres with same Z distance (0.5). Create an empty game object named Points and regroup these spheres.

Screen Shot 2015-03-24 at 15.29.29


There is no sphere at the end of plane because we will clone this plane and the first sphere of the clone plane will be there. In additional, create a sphere named RoadSphere and place it 0.5Z far from the first sphere as seen on picture. This sphere keeps location of the clone plane. All of these plane and spheres will be its children and and it will be located on the last sphere of current plane. That provides a continuously road for us. Edit hierarchy as RoadSphere>Plane>Points>P1, P2, P3, P4,….. Make it prefab.

For character, create a sphere named CharacterSphere. Create a Capsule for character as child of CharacterSphere. Rotate it 90X for a horizontal capsule. Attach camera to Character sphere to make camera follow character. You can use textures for a better experience. Pick some textures from google and attach it your objects.

Screen Shot 2015-03-24 at 16.02.33


The small sphere belongs to our character and the big onScreen Shot 2015-03-24 at 16.06.34e is P2 sphere of road. Now, you can hide these all spheres by clickling checkbox near the MeshScreen Shot 2015-03-24 at 16.08.06 Renderer title. You can select multiple spheres by holding CTRL. Now you get a clear view on game scene. We don’t need view of these spheres and we don’t need  their Mesh Renderers too.



Let’s start coding. We will 2 scripts for game controller and for collision. Create a C# script and don’t forget to add using System.Collections.Generic
because we will use lists.

This code checks at start if there is a road at scene. If not, checks if there is one road or more. If there are more than one, it destroys the old one. Code keeps all spheres and roads in a list to get information about them later in update method. New road will be added “LevelCount*19+LevelCount-1″th sphere. It is 20th sphere for the first clone after the road which is created at start. Now, call CreateNewRoad method at start.

I said that our character will follow spheres with Lerp method.

We assigned starPoint and endPoint for movement. Also, we use LookAt to check if there is a sphere after a few spheres or not. When our character reaches to 10th sphere, we create a new road. You can change these values but be careful, if you create new road at last sphere, you get an error because code checks 3-4 far spheres and it will be empty. Now, we can add keyboard controllers in Update method.

Create a folder named materialScreen Shot 2015-03-24 at 17.30.07s and create four materials for yellow, red, blue and black material. These materials give coins different colors. Add your materials as public objects to your script. Create a cube as an game object for coins.


Screen Shot 2015-03-24 at 17.33.30


Now, you may add collider to collect coins or a timer for a better gameplay experience.

You can download script file here.

©Coffee Break Codes – 3D Infinite Runner Game Tutorial – Unity3D (C#)

Leave a comment

Your email address will not be published. Required fields are marked *

75 thoughts on “3D Infinite Runner Game Tutorial – Unity3D (C#)

  • Nathanial

    I’m doing an internship diy wallpapering tips Iran’s Foreign Minister Mohammad Javad Zarif said in a television interview: “Iran’s peaceful nuclear programme should continue, and at the same time the West should be assured that the programme has peaceful purposes and will not be used to make weapons. I call this a win-win proposal.”

  • Darin

    Enter your PIN meninas wallpaper This idea is ridiculous!!! I have three boys at school and I cant afford to send them for school dinners. I’m on a low income but because I dont claim job seekers allowance my children are not entitled to free school meals. My children would have to go without ALL DAY!!

  • Curt

    this is be cool 8) best playstation wallpapers Iowa Attorney General Tom Miller, who took the lead in the joint state-federal investigation into the banks’ mortgage practices, said state lawmakers have the authority to do what they want with the money. “If policymakers in a particular state decided that the foreclosure crisis caused significant damage to their economy, one could make the case that that state should be able to use some of the settlement money to address that harm,” Miller said.

  • Haywood

    Recorded Delivery eso dual monitor wallpaper “Machete Kills,” the sequel to 2010’s “Machete,” also stars Danny Trejo, Michelle Rodriguez, Sofia Vergara, Amber Heard, Carlos Estevez (a.k.a. Charlie Sheen), Antonio Banderas, Jessica Alba, Alexa Vega, Vanessa Hudgens, Cuba Gooding Jr. and Mel Gibson.

  • Lance

    How much is a First Class stamp? dragon ball super 3d hd wallpaper “First, by measuring its redshift, we learned that it was pretty nearby as far as GRBs go,” he says. “It was pretty wimpy compared to most GRBs, liberating only about a thousandth as much energy as the most energetic ones. But we did see it eventually turn into a supernova. Typically we only detect supernovae in connection with nearby, subluminous GRBs, so we can’t be certain that cosmologically distant GRBs are caused by the same kinds of explosions.”

  • Homer

    Will I get paid for overtime? purple grey rose wallpaper California Governor Jerry Brown announced plans on Friday to seek an injunction to bar Bay Area Rapid Transit Districtworkers from striking for 60 days if the transit agency and itsemployees fail to resolve their contract dispute by Sunday.

  • Lowell

    I’m at Liverpool University feast wallpaper President Barack Obama pauses while speaking about the the budget and the partial government shutdown, Tuesday, Oct. 8, 2013, in the Brady Press Room of the White House in Washington. The president said he told House Speaker John Boehner he’s willing to negotiate with Republicans on their priorities, but not under the threat of “economic chaos.” (AP Photo/Charles Dharapak)

  • Garfield

    What’s the interest rate on this account? twilight wallpaper book The museum earned only $28,500 from its merchandise saleslast year, Goforth said, adding that “every penny of that isbeing used to further the museum’s mission of educating thepublic and preserving the area’s history.”

  • Brett

    Special Delivery wallpaper dead or alive The White House was supported by several senior members of Congress, including the Republican chairs of the Intelligence and Armed Services committees who had written a letter urging colleagues to reject the amendment.

  • Garland

    I’m self-employed priest 2011 movie wallpapers Dickson is a 25-year veteran of Zimbabwe’s Hwange National Park, and we were beginning to realise what an honour it was to have him lead us around. A guide can make or break a bush experience; while most are very knowledgeable, the ability to share that knowledge in a way that both inspires guests and meets their own understanding of the bush halfway is a rare skill indeed.

  • Austin

    What’s the exchange rate for euros? next purple stripe wallpaper “You can’t let perfect be the enemy of good,” Beshears says.”The sums we’re talking about are enormous, so take a smallstep. Do it in the near future. Overcome that initial barrier toaction by making the problem more manageable.”

  • Stephen

    I work with computers wallpaper the darkness Willetts, presently the Minister of State for Universities and Science, has never been admitted to the Cameroon inner circle, perhaps because he initially supported David Davis in the 2005 leadership contest (the PM has a long memory). The role of in-house “Deep Thought” was long ago entrusted to Oliver Letwin, who, in a Sunday Telegraph article in July 2005, became the first MP to endorse Cameron as a prospective leadership contender.

  • Kenton

    What line of work are you in? wallpaper crysis Yes there are a number of options available, you can set your browser either to reject all cookies, to allow only “trusted” sites to set them, or to only accept them from the site you are currently on.

  • Rickie

    What’s the current interest rate for personal loans? footballers wallpaper download “Dominique Ansel: The Secret Recipes” is scheduled to be published in October 2014, and, according to the press release, “will showcase Ansel’s artistry and versatility in a unique format.” The book will “teach novice and experienced bakers how to turn the simplest of ingredients (flour, sugar, butter) into the most extraordinary, tempting, and satisfying pastries imaginable-right in their own ovens.”

  • Nathanial

    Did you go to university? wallpaper the darkness BDFM Publishers (Pty) Ltd disclaims all liability for any loss, damage, injury or expense however caused, arising from the use of or reliance upon, in any manner, the information provided through this service and does not warrant the truth, accuracy or completeness of the information provided.

  • Frederic

    Looking for work wallpapers genelia Some market watchers prefer what is called the “ShillerP/E,” named after Yale University economics professor RobertShiller. Instead of comparing price and earnings data for thelast 12 months, or forecasting it for the next 12, the ShillerP/E relies on the previous 10 years of inflation-adjusted data.

  • Ariana

    I stay at home and look after the children wallpapers for motorola moto In October 2012, Carlyle bought 51 percent of Getty fromHellman & Friedman LLC, another private equity firm, which hadtaken the company private in 2008 for $2.4 billion. Getty’sco-founder and chairman, Mark Getty, and his family rolled intheir stake as part of the deal.

  • Charlotte

    Are you a student? where can i download naruto wallpapers for free With the oldest baby boomers now age 67, it will not be long before the generation begins needing old-age care. Even a healthy 80-year-old is likely to need assistance. Due in part to America’s rising obesity problem, baby boomers are not as healthy as the generation before them. They may live longer as a result of advances in medical care and pharmaceutical breakthroughs, but they will need ever-increasing amounts of care.

  • Marcus

    We work together daschund wallpaper Defense Secretary Chuck Hagel said on Wednesday that finding$500 billion in budget cuts required by law over the nextdecade, on top of $487 billion in cuts already beingimplemented, required tough trade-offs between the size of themilitary and high-end weapons programs.

  • Reynaldo

    A Second Class stamp italian mafia wallpapers On Friday, tens of thousands of Morsi supporters, many of them from the provinces, turned out for a mass protest in front of the mosque, filling up the large intersection and spilling some ways down the boulevards. Witnesses said that military helicopters dropped leaflets on the crowd encouraging them to leave the sit-in.

  • Jimmy

    Where’s the postbox? fondos escritorio wallpapers hd Executives from MWW and subcontractor Brushfire — which has been the state Department of Travel and Tourism’s ad agency the last seven years — made their pitch for the tourism advertising contract by saying they wanted Christie to have a starring role.

  • Coco888

    I really like swimming denver broncos wallpaper 2013 Burton, who has performed at the Edinburgh Fringe Festival and next year tours the UK, says X Factor rather than her ongoing battle with mental illness is the butt of a gag that helps ease tension when her audience seems uncertain as to how to react to her story.

  • Maynard

    On another call samsung s8 wallpaper resolution There have also been reports that Muslim Brotherhood supporters set fire to Coptic Christian churches in Sohag, south of Cairo. Egyptian Copts, who make up between 6% and 10% of the country’s population, have warned that Mursi supporters are targeting them in revenge for supporting the military-led removal of the president on July 3.

  • Stephan

    Could you please repeat that? large paisley pattern wallpaper
    Being a full-time caregiver to Callum led her to neglect her own health even further, relying on fast food in between lengthy doctor’s visits. She developed Upper Airway Resistance Syndrome, which is similar to sleep apnea. “It was always a struggle to find the time to exercise or cook healthy food,” she said.

  • Gerry

    Could you ask him to call me? sweet heart wallpaper Mom, there’s no need to worry about me blinding myself on moonshine or having an allergic reaction to the organic cheese — we’re under expert supervision. Raimondi and co-founder Ari Joseph, 30, successfully ran an Offsite in February and are planning another in October.

  • Isaias

    A law firm 3d clock live wallpaper apk The Novak Djokovic Foundation Gala Dinner was attended by celebrities and royals, including Princesses Eugenie and Beatrice and their mother Sarah Ferguson, Jonathan Ross, Tim Henman, Naomi Campbell and the actor Gerard Butler who watched the Wimbledon final on centre court with Hollywood’s Bradley Cooper.

  • Mason

    I’m interested in this position botanist wallpapers Greece’s international lenders – the EU, ECB, and IMF, known as the troika – are due to return to Athens in the autumn to reexamine whether Greece’s debt is on sustainable footing and whether the government needs to find further savings to meet its 2015-2016 budget targets.

  • Michal

    Remove card hd wallpaper desktop cars In an interview with the Lebanese Al-Akbar newspaper, Syrian President Bashar Assad was quoted Monday as saying that his country stopped manufacturing chemical agents in 1997 because they became an “outdated deterrent.” He said Syria has since concentrated on its missile capabilities.

  • Dominique

    I’ve got a part-time job pretty hustle wallpaper Later as Walt does his mad dash around the house, trying his best to coerce Skylar and Flynn into packing their belongings, it becomes evident that maybe this time Walt has gone too far (“Where’s Hank?”). Skylar takes a slow and steady walk to the bench. The wide shot reveals a knife block and a phone. Watch the scene slowly, her eyes are on the phone and we are led to believe she will pick it up, instead she reaches for the knife and the episode takes another shocking turn, one which ends with her running down the street chasing after her infant daughter. Falling to her knees, defeated, we see a look of true horror on Skylar’s face. To Anna Gunn’s credit, the look on her face is one we have never seen throughout 5 seasons of Breaking Bad, and rightly so. For many terrible things have happened, but nothing quite so terrible as losing your daughter.

  • Theodore

    A financial advisor captain rex star wars wallpaper So, with the anticipated culmination of this week’s events a massive military parade in Kim Il Sung Square on Saturday, the searchers will have to try again — an endeavor this group vowed to renew, despite the often belligerent rhetoric North Korea’s government aims toward Americans.

  • Ryan

    I went to top cars wallpaper Sporting scholarships at schools are not new – and the precise inducements offered to Scots’ students is not known – but the scale and the apparent success of the program appears to have angered fee-paying parents and other schools.

  • Kaylee

    Is this a temporary or permanent position? how to make your own wallpaper engine Ellie Kemper has finally made the crossover from bridesmaid to bride after she walked down the aisle on July 7, 2012. “The Office” actress, 32, wed her longtime boyfriend Michael Koman in a New York City ceremony, her rep confirmed to People. Kemper and Koman, a former writer for “Conan,” were joined by a host of family and friends, including the actress’ comedienne pals Kristen Wiig and Mindy Kaling. “In real life, I’ve been a bridesmaid like a dozen times and after doing that movie I thought maybe I’ll have some insight into wedding planning, but I took none of that insight,” she told E! News. “I’m as, panicky, as uptight as any bride ever was.”

  • Wilbert

    I came here to work free live christmas wallpaper backgrounds Syria agreed to eliminate its chemical stockpile after the United States threatened air strikes in response to sarin gas attacks which killed hundreds of people in Damascus six weeks ago. Washington blamed Assad’s forces for the incident, but Syrian authorities said rebels were behind it.

  • Teddy

    Lost credit card rude mobile wallpapers “This survey is a wake-up call for banks,” Deloitte said, emphasising changing attitudes towards them following thecrisis, rate-rigging and mis-selling scandals and regulatorypressure to overhaul their corporate culture.

  • Jack

    How many would you like? dulux wallpaper meadowsweet s/teal On Monday, Morsi supporters protested in northern Sinai, blocking a road in Beir el-Abd — a town leading to the provincial capital el-Arish. After the crowd clashed with residents, military troops cleared the road and fired in the air to disperse the crowd.

  • Elroy

    I’d like to withdraw $100, please how to spray texture over wallpaper Michigan City Fire Department spokesman Mark Baker told the newspaper he learned the child doesn’t have life-threatening injuries or a brain injury from any lack of oxygen he might have experienced. Wong said Saturday the boy had responded to simple commands Friday when he arrived at the hospital.

  • Burton

    Good crew it’s cool 🙂 wallpaper crysis This was severely opposed by Muri’s supporters, mainly Muslim Brotherhood and their allies from the fundamental Islamist groups, who took to barricading themselves in Rabia Al Adwia and Al Nahda square in Cairo. They brought women, children and supporters from the farming community from outside the capital, and stayed there for the whole month of Ramadan. That was not acceptable for the new administration, backed by the military, resulting in the government’s decision to clear the barricade in an operation that witnessed the loss of hundreds of Egyptian lives during the standoff.

  • Vida

    How do I get an outside line? microsoft home digital wallpaper Proponents call the TPP, the most ambitious trade pact since the demise of the Doha round of global talks, a “high-standard” agreement to eliminate tariffs and tackle an unprecedented range of non-tariff barriers that restrict growth.

  • Ellis

    Could you send me an application form? murderdolls wallpaper “The Pistorius family does not wish to comment on any aspects of this court case before the next court appearance,” Anneliese Burgess told the AP in an email. “In our view, the correct place for any information relating to charges or witnesses or any other aspects pertaining to this or any other legal case, is in a court of law court.”

  • Addison

    I’d like to send this to hussyfan little girls “If a physician takes advantage of every hearing, every right to trial, it takes much, much longer” to resolve a case, says Robinson, the medical board’s director. “He took advantage of every hearing, everything.”

  • Charlie

    Where are you calling from? jailbait chan toplist A spokesman for Orange declined comment on the Dominican Republic business, but said the group regularly conducted reviews of its assets, aiming to “analyze their performance, growth potential and coherence with the group’s strategy”.

  • Clarence

    In a meeting underage tube Students from the middle school and neighboring elementary school were evacuated to a high school after the shooting, and all classes were canceled. The middle school will remain closed for the week, while an adjacent elementary school is set to reopen Wednesday.

  • Evan

    Do you need a work permit? nizagara 100 dosage But the feat of keeping supporters’ passions burning, and ferrying them from so many disparate locations to the heart of the capital for the ongoing vigil, is a remarkable achievement for an organization whose senior leaders are now on the run from the authorities. The government says it will not stop peaceful demonstrations.

  • Alphonse

    I’d like to order some foreign currency legal underage nudity It isn’t the first time the singer has flexed his acting muscles. Usher explains that he’s been able to incorporate his skills as an entertainer — especially as a dancer — into his movie work.

  • Warren

    Could you send me an application form? nn models young Regardless of the outcome, the U.S. military is not expected to free Bahlul from Guantanamo. It could pursue different charges against him or detain him indefinitely, a power the U.S. government claims as part of its war against al Qaeda.

  • Lucius

    Whereabouts are you from? when to take nizagara If the Rockies could sell such a projection to their fans, they might be more willing to fill out a trade package with pitching, which remains their weakness, as evidenced by their National League-low team ERA. And young pitching is clearly the strength of the Mets’ farm system.

  • Warren

    What do you do for a living? yuvutu tube mobile
    In Virginia, Bostic and London had their marriage request denied, setting up a scenario where Boies and Olson can have another crack at a history-making, legalize-gay-marriage-everywhere Supreme Court ruling.

  • Orval

    Who’s calling? yuvutu While the 4G licences are expected to be based on TD-LTEtechnology, rather than the more widely-used FDD-LTE, the newQualcomm chips can handle both systems, saving Apple from amajor re-design just for the Chinese market, albeit the world’slargest.

  • Harvey

    Your account’s overdrawn yuvutu tube The owner of one of the bathing establishments said he saw some of the migrants running from the shore to a nearby road. “I saw a group of them trying to make it to the road from the beach” and called authorities, said Dario Monteforte.

  • Carson

    Could I ask who’s calling? al4a Joseph Dutton, of Leicester University, told the BBC fracking presented “minimal danger” of water contamination if done properly, as the cracks it created were far deeper underground than aquifers.

  • Antwan

    I’m in my first year at university yuvutu tube But after millions took to the streets to unseat now former Egyptian president, Mohamed Morsi, prompting the army’s seizure of power, the Islamists are also worried about potential backlash once they end up in government.

  • Brian

    I’ll text you later cialis wanking “It’s just so hot. I keep wandering around thinking, where is the oxygen today?” asked Nielson. “I like `on demand’ ice cream, especially when it’s this hot. I’m sure a lot of people want it right now. We got lucky.”

  • Diana

    How much is a Second Class stamp? al4a Under the change, first officers or co-pilots will berequired to have 1,500 hours of flight time to hold an AirlineTransport Pilot certificate, up from 250 hours that wererequired under previous standards, the agency said in astatement.

  • Emmanuel

    When can you start? al4a tube The Meteorological Agency said the storm dumped an “unprecedented” amount of rainfall in Kyoto and two neighboring prefectures, dumping as much as 8 centimeters (3 inches) per hour. It lifted a “special warning” for the area Monday.

  • Fidel

    good material thanks al4a tube The widescreen version of Navman’s entry-level navigation unit comes with such features as Lane Guidance and Junction View to ensure the user never takes another wrong turn. The menu system is intuitive and the screen is clear and easy to read. For a three-month free trial period it also warns of speed cameras.

  • Savannah

    I can’t get a dialling tone wallpaper rdj White House advisers point out that polls show most voters oppose the House GOP strategy of refusing to fund the government unless Obama’s health care law is defunded, delayed or otherwise undermined. Republicans consider the Affordable Care Act harmful to the economy and an unwise increase in the power of the federal government. Americans are split on the law, but GOP legislators have such low standing with the voters that their arguments don’t seem to be working as they make the case for defunding Obamacare.

  • Wyatt

    I’m training to be an engineer al4a tube But perhaps the most important takeaway from whatever the Fed decides next month will be that the process of crafting monetary policy is never a purely academic exercise. The path they choose will necessarily be a compromise between economic theory and financial reality, as well as the wide range of personalities who make up the committee.

  • Kenton

    We need someone with qualifications al4a videos Santander Brasil has for years held capital in excess ofcentral bank requirements. The plan also includes a reversesplit of its common and preferred shares, with no impact to unitvalue. (Reporting by Guillermo Parra-Bernal; Writing by Reese Ewing;Editing by Christopher Cushing, David Holmes and Diane Craft)

  • Rudolf

    My battery’s about to run out yuvutu tube mobile
    Its not a car for everyone. But I would disagree with the description of “morbidly obese, frumpy and ancient” (Norma Smellons). For its owners it fulfils a purpose. Its weight gives it towing ability. It is more practical than any MPV I can think of. It has a timeless design & a luxurious interior without the chavvy image of the RR Sport. It is comfortable yet can rival a Defender off road. In many ways it is the ideal family car.

  • Chadwick

    I’m self-employed imageboard pthc As I watched the sewage-tainted waters of the Big Thompson roll by, two contract engineers walked up. They had hoofed it down-canyon for several miles, assessing the damage. They envied my bike aloud and said their job is to put the river back where it belongs and repair the road as fast as possible.

  • Ezequiel

    Free medical insurance al4a videos The national economy will likely be back to recovery by early 2014 after Congress and the White House reached a bipartisan deal that reopened the federal government and raised the debt ceiling, according to Steven G. Cochrane, managing director of Moody’s Analytics.

  • Kevin

    How much notice do you have to give? al4a Syrian rebels and activists have been dismayed by signs of what they see as U.S. reneging on its support for Assad’s opponents – by deferring any threat of military action and then reaching a deal with the Syrian president over chemical weapons.