Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Mrkrisher · Nov 03, 2016 at 08:29 PM · teleportteleportingportaltransferportals

How to create a portal/teleport.

I have a game where you roll a ball around, avoid obstacles, and collect as many yellow cubes in the given time. How do I create a portal so that if a player goes on to a certain spot, they will be teleported to another area in the same scene? I'm fine with either an invisible portal that the player unknowingly goes in or like an actual oval-shaped portal that the player can see and just go through. All answers are appreciated. Thanks in advance!

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
1

Answer by Josp101 · Nov 03, 2016 at 10:30 PM

Make an object that you want to be the portal (can be invisible if you want).

Add a collider to the object so that the ball collides with the object when you want it to be teleported. Then just add a script to the ball.

     void OnCollisionEnter(Collision collision) {
 
         if(collision.gameobject.name == "invisible portal")
            gameobject.transporm.position = new Vector2( *some position*)
 
     }

This C# code is untested and this is just one very simple way of making a portal.

Comment
Add comment · Show 4 · 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 Mrkrisher · Nov 03, 2016 at 11:41 PM 0
Share

What type of collider should I add?

avatar image Josp101 Mrkrisher · Nov 04, 2016 at 06:25 PM 0
Share

If this is a 3D game then you should just use any 3D collider (sphere, box, etc.).

It just depends on where you want the ball to be teleported from.

avatar image Mrkrisher Josp101 · Nov 04, 2016 at 08:43 PM 0
Share

I might have done something wrong but an error message came up

alt text

screen-shot-2016-11-04-at-112546-pm.png (55.9 kB)
Show more comments
avatar image
0

Answer by Breeziggy · Feb 14, 2018 at 02:48 PM

@josp101 I tried this code for my game but it's saing i have a error at void OnCollisionEnter(Collision collision) { and it's saying it with the void. What should I do?

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 Josp101 · Feb 16, 2018 at 05:59 PM 0
Share

I gave this answer 2 years ago but I believe I made an error:

It should be:

 if(collision.gameObject.name == "invisible portal")

(the change is gameobject to gameObject)

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

59 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 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 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

Teleporting MainCamera and GameController 1 Answer

What is wrong with my 2D portal code? 0 Answers

Making Portals 2 Answers

Script for teleport on collision? 2 Answers

Destroying a prefab bullet after time with the list 0 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