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 ProGrahamCracker · May 05, 2015 at 10:20 PM · cameraterrainrpgdesignlarge

What options are practical for returning a character to (0,0,0)?

In my game I have a very large world (Infinitely large for the sake of argument). The play style is a birds eye view hack and slash. The terrain is flat, there are no real hills or dips for rivers. I don't want to move the world while my character stays fixed in the center unless that is the best option. There can potentially be 100 different objects that the character can interact with in some manner (fighting, collecting, destroying, colliding against). My terrain is build up of "tiles". What I would like to do is, move the character and as it progresses load and unload different tiles, my problem is the size of the world. After my character is adventuring out at lets say (10,000, 0, 10,000) (which is farther than I would like to let it get), how can I bring it back to (0, 0, 0) with minimal visual hiccups? I have read about recreating the scene at (0, 0, 0) and then jumping the camera, but I didn't know if there were better options. This is a mobile game and I need to keep my active game object overhead as low as possible to allow for more content, however I am prepared to build around constraints like these.

Thanks for the advice and help.

Comment
Add comment · Show 3
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 AsierDedo · May 06, 2015 at 10:44 AM 0
Share

I'm not sure if I have understand you, but, what if you try to change its position?

transform.localPosition = new Vector3(0,0,0);

avatar image ProGrahamCracker · May 06, 2015 at 01:48 PM 0
Share

that would work however I would need to change the position of everything in the scene to (0, 0, 0). Changing the position of that many objects can look glitchy. I would need to change the position of projectiles and monsters and landscaping so that when they all land at (0, 0, 0) the user has no idea I reset the scene to (0, 0, 0).

avatar image AsierDedo · May 06, 2015 at 01:57 PM 0
Share

Have you tried to reload de scene? I think its not what you are looking for, but it could be another way.

Also you can use a foreach, move all objects inside an empty GO use the GO for apply this code:

 Transform[] children = transform.GetComponentsInChildren<Transform>();
 foreach (Transform child in children){
     transform.localPosition = new Vector3(0,0,0);
 }

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by scarletshark · May 06, 2015 at 02:19 PM

Parent all interactable objects underneath your world tiles, and asyncronously load a new tile as you reach the edge of your current world tile. When you reach the new tile, you could use the collision event to trigger its movement so you don't have to constantly be looking for if(transform.localPosition.x > 10000).

Then on the new world tile GameObject, you can put this script:

 void OnCollisionEnter(Collision collision) {
     if(collision.tag == "Player"){
         transform.position -= collision.transform.position;
     }
 }

The only issue with this is if your character has a jumping or falling animation. Every time he lands, this will run. So perhaps you want to put box colliders on the edge of your world tile, and only run the script when the player interacts with them.

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

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

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What is a reasonable size for a terrain in a top-down RPG? 1 Answer

Camera 2D RPG in perspective 1 Answer

Prevent Camera from going off terrain 0 Answers

Close To Camera Objects 0 Answers

Camera is culling terrain detail objects regardless of settings 6 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