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 /
  • Help Room /
avatar image
1
Question by soni_saurabh · Jun 10, 2020 at 12:09 AM · teleporting

teleport to and fro between surfaces at different heights

i have surfaces at different heights (32 meters between each other) like inside a building.

I want teleport the player between different floors of the building to and fro.

i am new to unity and i created teleport pads and target plane along with its C# script from one floor to the next as below alt text but in order to make the player go to the next floor do i have to create another teleport pad and target and another C# script

also if i want to go back to the previous floor, do i have to create a separate script for that too?

does it have to be a tedious process of so many scripts or just one script can be amended?

annotation-2020-06-10-100821.png (19.1 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by magicdog2013gamez · Jun 10, 2020 at 04:50 AM

It doesn't know what the destination is Try something like this

 public enum TriggerType {Enter, Exit};
 
     [Tooltip ("The Transform to teleport to")]
     [SerializeField] Transform teleportTo;
 
     [Tooltip ("The filter Tag")]
     [SerializeField] string tag = "Player";
 
     [Tooltip ("Trigger Event to Teleport")]
     [SerializeField] TriggerType type;
         void OnTriggerEnter (Collider other)
         {
             if (type != TriggerType.Enter)
                 return;
     
             if (tag == string.Empty || other.CompareTag(tag))
                 other.transform.position = teleportTo.position;
         }
     
         void OnTriggerExit (Collider other)
         {
             if (type != TriggerType.Exit)
                 return;
     
             if (tag == string.Empty || other.CompareTag(tag))
                 other.transform.position = teleportTo.position;
         }
     }

The exit is the destination and the enter is the start, Tell me if it doesn't work I just quickly attempted to convert it from 2d to 3d

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 soni_saurabh · Jun 10, 2020 at 05:18 AM 0
Share

Thanks for your help. i will try your method once i am more acquainted with scripting.

while waiting for any reply, i actually could create multiple teleport pads and targets by using copy paste command and only changing their teleport(script) references. there was no need to create multiple scripts which i had feared.

attached is a screenshot below and it worked really fast to setup for moving between floors.

alt text alt text

annotation-2020-06-10-100821.png (19.1 kB)
capture.png (205.2 kB)

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

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

Using Raycast and Layermask to teleport player in VR, but the Raycast teleport initiates through objects of a different layer 0 Answers

How to check for colliders when teleporting the player in a 2D game? 0 Answers

Having trouble teleporting player in a 2D game 0 Answers

Why is my isLocalPlayer not working ? 0 Answers

Unity Flashback effect 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