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
1
Question by timrox99 · Oct 02, 2014 at 08:40 AM · triggerteleportsimpleeasy

How can I teleport objects.

Hey, so I thought it would be meaningless to post such a short and easy script so I thought I might as well just ask the question. Call me noob, but is there a way I can get my character controller to teleport to a certain position on the axis without switching scenes when I enter a trigger area?

If you can help, can you please demonstrate a simple example script of how this could work using a trigger. Help would be greatly appreciated, Thanks.

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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Brascal · Jul 16, 2015 at 09:15 AM

Here is a completed script for teleporting object. Add this object witch will teleport player a new place.

public Transform exit; public Transform myplayer;

void OnTriggerEnter(Collider other) { if (other.CompareTag("Player Event Trigger")) {

         myplayer.position = exit.position;
       
        // Camera.main.transform.position = new Vector3(myplayer.position.x, myplayer.position.y, -10);// this code if you want make 2D game. Or you have a 3 person animation camera
     }
 } 


Remember public Transform exit will be a empty game object witch spawn player.

If you have more than one teleport exit areas. Make a array public enum. Enum you can choose what port will be execute.

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
avatar image
0

Answer by Quaker_SDR · Oct 02, 2014 at 08:57 AM

void OnTriggerEnter(Collider other) { transform.position=<Desireposition>; }

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 timrox99 · Oct 02, 2014 at 09:35 AM 0
Share

Thanks for the help.

avatar image
0

Answer by leowu4ever · Oct 02, 2014 at 10:25 AM

I assume you talking about teleport a GameObject in one scene. That means you try to change its position. You can specify a destination by placing a Quad on a certain position.

For the place you want to enter and do the teleport, just attach a script which contains OnTrigger method. Like below.

Let me know if you still having problem.

alt text


qq20141002-7.png (74.3 kB)
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
avatar image
0

Answer by Shirokov · Jul 09, 2015 at 06:31 AM

Have you tried to watch the teleporter grenade tutorial?

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

6 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

Need help making an audio trigger. 2 Answers

Quick Custom Inspector Question 1 Answer

Glitchy Turret Script 2 Answers

Problem with OnTriggerEnter() 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