Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Lucifer95 · Jul 22, 2014 at 09:30 PM · infiniterunner

trying to make infinte runner,but cannot position tracks.

hey guys, am trying to make infinte runner with 3 tracks, adding 1st to end of 3rd when player passes trigger of 1st track. all three triggers at end are child of that track. but tracks are positioned at random position also tried subtracting or adding values but to no vail as below.

my code::

using UnityEngine; using System.Collections;

public class loop : MonoBehaviour {

 public Transform stage1;
 public Transform stage2;
 public Transform stage3;
 public Transform trigger1;
 public Transform trigger2;
 public Transform trigger3;
 public int speed=10;
 
 // Update is called once per frame
 void Update()
 {
     transform.Translate (0, 0, .5f);
     
 }
 void OnTriggerExit(Collider other) 
 {
     if (other.name == "trigger1") 
     {
         stage1.Translate (0, 0, (stage3.position.z+100     )  );
         Debug.Log("stage3="+stage3.position.z);
         Debug.Log("stage1="+stage1.position.z);
         Debug.Log("trigger1="+trigger1.position.z);
     }
     if (other.name == "trigger2") 
     {
         stage2.Translate(1, 1, stage1.position.z + 100  );
         Debug.Log("stage2="+stage2.position.z);
         Debug.Log("trigger2="+trigger2.position.z);
     }
     if (other.name == "trigger3") {
         stage3.Translate(1,1,stage2.position.z + 100);
         Debug.Log("stage3="+stage3.position.z);
         Debug.Log("trigger3="+trigger3.position.z);
     }
 }

}

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Lucifer95 · Jul 23, 2014 at 05:41 AM 0
Share

yup,snapping positions worked.thanks a lot

avatar image Lucifer95 · Jul 23, 2014 at 05:50 AM 0
Share

i have attached capsule collider to player,and box collider to walls on sides of track and made it kinematic, but then also player moves through wall and fall down.

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by markedagain · Jul 23, 2014 at 12:46 AM

i think translate wont work if there is no rigidbody attached to the object. have u tried simply snapping them into position using transform.position ?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by WilliamLeu · Jul 23, 2014 at 01:41 AM

You need to

  1. place the entirety of a single track in a single game object, that way you can move an entire track by just transforming 1 root transform (I'm assuming there's going to doodads and artwork attached as separate GameObjects.

  2. Place by hand a GameObject both at the beginning and end where one track meets another and have access to them in the script. Again, these are going to belong to the parent GameObject mentioned above in requirement 1.

Then when attaching the beginning of TrackB to the end of TrackA, find the difference between where TrackB is in the world, and where you want it to be, and move it by that much...

TrackB.transform.position += TrackA.TrackEnd.transform.position - TrackB.TrackBegin.transform.position.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Lucifer95 · Jul 23, 2014 at 05:31 AM 0
Share

gonna try that too

avatar image
0

Answer by RedDevil · Jul 23, 2014 at 06:01 AM

I did this without using parallax by spawning objects at certain positions and then destroying them after they passed the main camera(this is good if you are making a mobile game).I just atached to the pictures a rigidbody and gave them velocity to move in that direction.If you do this you just have to time them perfectly to spawn one after another.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Lucifer95 · Jul 23, 2014 at 06:15 AM 0
Share

thats true, but am gonna spawn coins on switch case, to spawn on right,middle and left. also by parallax i can make terrain seem to move,that cannot be done with tracks moving, coz it will hit performance.

avatar image RedDevil · Jul 23, 2014 at 06:44 AM 0
Share

i did this with several layers over 2D game and it is running very smootly on iPad

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Infinite runner: obstacles not initiating correctly after the second time 0 Answers

2d Random object placement help? 1 Answer

Spawning objects in infinite scroller game 0 Answers

Infinite Runner Tutorial - Destroyer Problem 2 Answers

Infinite runner world creation 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges