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 gogo199432 · May 13, 2014 at 11:20 AM · buginspectorteleportingstrange

Teleporting Player doesn't work as expected?

Hi guys!

So I have a very strange problem again. I wrote a basic teleportation script which is working fine at the first point. I enter the trigger, and it teleports me to a given gameobject's position. However when I do the same on another trigger because I want a way back to my original position, for some reason it teleports me to the first teleport's target coordination. To better understand: Teleport1 - Teleport1Target Teleport2 - Teleport1Target

Obviously I want the Teleport2 to lead to Teleport2Target, but it doesn't even after I make sure that it has the right gameobject as reference in the inspector.

Here is the code:

 #pragma strict
 
 private var Player : GameObject;
 var Position : Transform;
 var delay : float;
 private var IsInRange : boolean;
 
 function Start()
 {
     Player = GameObject.FindGameObjectWithTag("Player");
 }
 
 function OnTriggerStay (theCollider : Collider)
 {
     if (theCollider.tag == "Player")
     {
         IsInRange = true;
         if(delay <= 0)
         {
             Player.transform.position = Position.position;
         }
     }
 }
 
 function Update()
 {
     if(delay > 0 && IsInRange)    delay -= 1*Time.deltaTime;
     if(delay < 0)    delay = 0;
 }
 
 function OnTriggerExit()
 {
     IsInRange = false;
 }
Comment
Add comment · Show 6
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 RyanPaterson · May 13, 2014 at 11:59 AM 0
Share

$$anonymous$$ight not be the problem, but I think 'Position' is a keyword in the unity sdk. It'd be good practice to name it something that's not, example ' var pos : Transform;

Is that what you attach teleporter objects to in the inspector?

avatar image Cerbion_ · May 13, 2014 at 12:23 PM 0
Share

So to get this straight, you have 2 Gameobjects (Teleporters) and you set the destination for the Teleport in the Inspector (Position).. Did you make sure that the second Gameobject/Teleporter has the right teleport coordinates? (and not just the same as the first Teleporter)

avatar image gogo199432 · May 13, 2014 at 12:31 PM 0
Share

I tried rena$$anonymous$$g the variable as you suggested, but it still does the same. And yes, I made sure that they have the right objects assigned to the variable. One of them is name TeleportPoint and the other is TeleportPointBackwards, so there is no way to mistake one for the other.

avatar image Addyarb · May 13, 2014 at 12:38 PM 0
Share

There's an awesome prefab package that has very solid code and can be easily modified if need be. https://sites.google.com/a/dopplerinteractive.com/contact/home/Teleporter_Example.unitypackage?attredirects=0

avatar image gogo199432 · May 13, 2014 at 04:26 PM 0
Share

I checked your package, but it doesn't really fixes my problem. The script in that package differs from $$anonymous$$e so that it teleports player between "2 pads" and not just simply drop him off at a location.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by gogo199432 · May 14, 2014 at 12:06 PM

Okay, so after sleeping I finally found out what was wrong with my teleportation script. There was nothing wrong with it! The only problem was that the second teleport had it's destination in the volume of the first teleporter, this means that the second teleporter did transfer the player to the right place, but before anyone could notice it, the first teleport transfered him again. So I just made the first teleporter to disable after the first transmission, and it is working now correctly :)

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

22 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

Related Questions

Inspector preview overflow 0 Answers

Game works fine in editor, but build fails with 59 error in the console 2 Answers

UnassignedReferenceException when its already assigned 1 Answer

Unity Weird Inspector Layout Behavior: Can't Scroll To the Bottom of Component Fields 8 Answers

Unity4 Ignoring Inspector/Initialized Public Value in Build 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