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 Tree · Sep 28, 2012 at 07:49 PM · round

how do you make a map which can be circumnavigated?

im trying to make a map which if you go to one edge you appear at the otherside.

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 Kiloblargh · Sep 29, 2012 at 06:26 PM 0
Share

*circumnavigated

avatar image Captain_Dando · Jan 22, 2013 at 02:33 PM 0
Share

This might be jumping the gun, but if you're thinking of making a world map kind of like the old play station final fantasies, I would say a good solution is to create the map as a sphere which rotates under the character as he plays his run animation. I previously tried creating a flat world map, but I ran into a problem where even though I was able to position my character to the other side once I reached the end, the change of textures was jarring, no matter how hard I tried to make it similar. Was I at least correct in my assumption that that is what you want to do?

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by ThunderAwesome · Sep 28, 2012 at 08:31 PM

I have an example project showing how it works at this link: http://dl.dropbox.com/u/105851962/Wall_Test.zip

EDIT: Package with the solution - http://dl.dropbox.com/u/105851962/Circumvent_Package.zip

EDIT AGAIN: Links have been updated! (Should Work)

You can place Collider boxes at the edges of the map (assuming it is square) and simply position your character at the Collider box on the other side of the map with a bit of an offset so they don't infinitely collide with a collider box and change their position.

So, if you character collides with the right side of the map, they would simply be transitioned to the left side of the map. Apply this script to your character:

 using UnityEngine;
 using System.Collections;
 
 public class Circumvent2 : MonoBehaviour 
 { 
     //DISCLAIMER: Feel free to use this script and Projectfor whatever you need it for. - ThunderAwesome 
     /// 
     /// Instructions 
     /// Assign all the wall GameObjects to their respective object. 
     /// Set the tags to each wall whatever it should be (I.E. - rightWall's tag is "Right_Wall") 
     /// Set the offset to whatever you want it to be...just make sure the character doesn't fly off the edge. 
     /// Offset should be positive for the Right and Top wall and negative for Left and Bottom... 
     /// Example: transform.position = leftWall.transform.position + new Vector3(offset, 0, transform.position.z); 
     /// Works with Right wall. AND transform.position = leftWall.transform.position + new Vector3(transform.position.x, 0, offset); 
     /// Works with Top wall. /// Example: transform.position = leftWall.transform.position + new Vector3(-offset, 0, transform.position.z); Works with Left wall. 
     /// Notice offset has a negative sign before it now. 
     /// Try implementing the other walls and taggin them correctly! 
     /// 
     public GameObject leftWall; 
     public GameObject rightWall; 
     public GameObject topWall; 
     public GameObject bottomWall;

     private float offset = 1.0f; 

     //used to set the Gameobjects to their respective
     //object, so you don't have to assign them. Just make
     //sure you name them correctly.
     void Start()
     {
         leftWall = GameObject.Find("Left_Wall");
         rightWall = GameObject.Find("Right_Wall");
         topWall = GameObject.Find("Top_Wall");
         bottomWall = GameObject.Find("Bottom_Wall");
     }
     
     //You'll need to have your Box Collider's isTrigger 
     //set to true for this function to work. 
     void OnTriggerEnter(Collider other) 
     { 
         //if the player collides with the rightWall 
         if(other.gameObject.name == "Right_Wall") //i usually check tags but this might work (can't test since I'm at work) 
         { 
             //set character position to left_wall + offset 
             transform.position = leftWall.transform.position + new Vector3(offset, 0, transform.position.z); 
         } 
         if(other.gameObject.name == "Left_Wall") 
         { 
             transform.position = rightWall.transform.position + new Vector3(-offset, 0, transform.position.z); 
         } 
         if(other.gameObject.name == "Top_Wall") 
         { 
             transform.position = bottomWall.transform.position + new Vector3(transform.position.x, 0, offset); 
         } 
         if(other.gameObject.name == "Bottom_Wall") 
         { 
             transform.position = topWall.transform.position + new Vector3(transform.position.x, 0, -offset); 
         } 
     }

     //Inserted this to make debugging easier.
     void Update()
     {
             //Press "R" to reset the scene
         if(Input.GetKey(KeyCode.R))
             Application.LoadLevel(0);
     }
 }
 

Adjust the values as needed. Make sure to set all the walls to their respective walls. I hope that helped.

Comment
Add comment · Show 9 · 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 Tree · Sep 29, 2012 at 09:11 AM 0
Share

i have been having trouble with this i have tried tinkering around with it but i cant get any of the other wall exccept right to work here is the code main code i mess about with

using UnityEngine; using System.Collections;

public class Circumvent : $$anonymous$$onoBehaviour { //DISCLAI$$anonymous$$ER: Feel free to use this script and Projectfor whatever you need it for. - ThunderAwesome /// /// Instructions /// Assign all the wall GameObjects to their respective object. /// Set the tags to each wall whatever it should be (I.$$anonymous$$ - rightWall's tag is "Right_Wall") /// Set the offset to whatever you want it to be...just make sure the character doesn't fly off the edge. /// Offset should be positive for the Right and Top wall and negative for Left and Bottom... /// Example: transform.position = leftWall.transform.position + new Vector3(offset, 0, transform.position.z); /// Works with Right wall. AND transform.position = leftWall.transform.position + new Vector3(transform.position.x, 0, offset); /// Works with Top wall. /// Example: transform.position = leftWall.transform.position + new Vector3(-offset, 0, transform.position.z); Works with Left wall. /// Notice offset has a negative sign before it now. /// Try implementing the other walls and taggin them correctly! /// public GameObject leftWall; public GameObject rightWall; public GameObject topWall; public GameObject bottomWall; private float offset = 1.0f; //You'll need to have your Box Collider's isTrigger //set to true for this function to work. void OnTriggerEnter(Collider other) { //if the player collides with the rightWall if(other.gameObject.tag == "Right_Wall") //i usually check tags but this might work (can't test since I'm at work) { //set character position to left_wall + offset transform.position = leftWall.transform.position + new Vector3(offset, 0, transform.position.z); } if(other.gameObject.tag == "Left Wall") { transform.position = leftWall.transform.position + new Vector3(-offset, 0, transform.position.z); } if(other.gameObject.tag == "Top Wall") { transform.position = bottomWall.transform.position + new Vector3(offset, 0, transform.position.x); } if(other.gameObject.tag == "Bottom Wall") { transform.position = topWall.transform.position + new Vector3(-offset, 0, transform.position.x); } //do the same for the other walls...but make sure //they are switched to the correct positions and such }

avatar image ThunderAwesome · Sep 29, 2012 at 03:03 PM 0
Share

$$anonymous$$ake sure you tag the objects correctly. If you click on the right wall in the scene and look at the inspector you'll see the right wall is tagged "Right_Wall". Create your own tags for each of the other walls. Or to make it easier you could do this:

//Look for the object by name not tag //So whatever you named the object you //compare to see if it is that object here. if(other.gameObject.name == "Right_Wall") { //offset code stuff }

Also, for offsetting the player, I noticed that you just changed the: new Vector3(offset, 0, transform.position.z); to to something like (-offset, 0, tranfsorm.position.x); What you have to do is actually set it to: (transform.position.x, 0, offset) and (transform.position.x, 0, -offset) to get it to work for the top and bottom.

I changed my code around to show the solution.

avatar image Tree · Oct 01, 2012 at 04:53 PM 0
Share

this is just an extension of the main question but is it possible to have like a camera on the opposite sides of the side you entering so you can see throught wall in a sense towards the other side .So it gives the appearance of never ending.Of course i only make it so you can see only so far through a wall before teleporting to the other side

avatar image ThunderAwesome · Oct 02, 2012 at 01:42 AM 0
Share

Like Portal? When you look through the Portals it looks never ending. Is that what you mean?

avatar image Tree · Oct 02, 2012 at 03:57 PM 0
Share

yes thats what i mean

Show more comments
avatar image
0

Answer by Kiloblargh · Sep 29, 2012 at 06:43 PM

It depends on how your map is and how you are moving your character, but colliders probably aren't the most efficient way to do it- you can also just check the character's transform x and z positions and move it if they go over or under a certain value. I f you had a circular game map, you could check the distance from the center point and move the character twice that distance in the direction back to the center. If you have a lot of other items/ enemies / whatever that could be getting warped from one side to the other in addition to the player, go with the colliders.

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

13 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

Related Questions

GUI Menu After every round how do I display a random image? 1 Answer

Zombie Round Script Help 1 Answer

Rounds increasing exteremely fast 1 Answer

Round x, y and z values of object? 1 Answer

Rounding up Damage to an Int 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