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 Shooter · Dec 07, 2011 at 06:37 PM · movementscreendisappearappear

Realize toroidal movement

Hi guys! I've some doubt on how to realize a toroidal movement. Beneath you can find an image that explain what I mean for "toroidal movement" (remember the old snake on the nokia 3310?).

I want my game object to gradually disappear when it goes on the border of the screen and appear gradually on the opposite. Looking to the image I guess is more clear:

alt text

Let's suppose that the arrow is my game object and the grey part the iPhone Screen.

Thanks in advance to all of you that will be of help!

S.

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by syclamoth · Dec 07, 2011 at 06:49 PM

Simple- have a second 'body double' object which moves in on the other side of the screen in perfect sync! Just keep a second object slaved to the first one, set up so that it would come onto the screen as soon as the 'real' one disappeared. Then, when one is totally off, delete the unneeded one and make the new one the 'real' one.

You'd need one set of body doubles for each dimension, assuming this works at the top as well. In fact, if you made every second body double mirror inverted, it'd be like a klein bottle instead!

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 Shooter · Dec 07, 2011 at 10:20 PM 0
Share

Thanks for the quick answer! I think it's a good idea, I'll try to implement that feature tomorrow ;)

avatar image
0

Answer by Shooter · Dec 12, 2011 at 12:03 PM

At the end I solved it in another way. I made 4 invisible wall as a container of the scene and create a script for each wall that make every wall triggered and take decision with reference of the function OnTriggerStay(). When the center of mass of the gameobject exceed the position of the wall the gameobject is teleported. This means that its coordinates are changed of a certain factor that is the height and/or the width of the screen.

Below the code I used on a wall:

 public class NorthWallTeleportation : MonoBehaviour {
     
     void Start(){
         this.collider.isTrigger = true;
     }
     
     void OnTriggerEnter (Collider collider){
     }
     
     void OnTriggerStay(Collider collider){
         if(collider.gameObject.tag == "TagOfTheObjectYouWantToTeleport" && collider.gameObject.transform.position.x < this.transform.position.x){
             collider.gameObject.transform.position = new Vector3(collider.gameObject.transform.position.x+2.9f,collider.gameObject.transform.position.y,collider.gameObject.transform.position.z);
         }
     }
     
 }

The 2.9f factor that I used here is the width of my screen and the fact that I add this factor to the x coordinate depends on the scene orientation.

Hope this is usefull.

Best,

S.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Window flicker when moving camera 2 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Making a bubble level (not a game but work tool) 1 Answer

Make enemy appear in front of player and then disappear at random times 2 Answers

How do you find an object in the middle of the screen? 1 Answer


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