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 Moltvatch · Feb 14, 2011 at 06:37 PM · positiondoorteleport

Teleport script, who can help me?

here is a script I made:

function OnTriggerEnter(other : Collider) { if (Input.GetKeyDown ("e")) Application.LoadLevel (1); }

function Awake () { DontDestroyOnLoad (transform.gameObject); transform.position = Vector3(71,79,-456); }

I used it in a door object/mesh, and when I start the game the door suddenly disapear why? I didnt turned the "trigger button

Then I deleted the function awake and the door didnt disappear anymore but the script didnt work either.

please help me!

All i want to do is that the FPS controller teleports to a new scene/level when he preses e in front of the door with the exact position.

As some can guess I still a big noob, I'm aware that I ask for a big help here but it takes time before I can manage all this on my own. thank you.

Comment
Add comment · Show 3
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 Jessy · Feb 14, 2011 at 07:43 PM 1
Share

Please select your code and press the 101010 button in the future.

avatar image Moltvatch · Feb 14, 2011 at 09:00 PM 0
Share

Allright, i get what you mean.

avatar image Moltvatch · Feb 14, 2011 at 09:01 PM 0
Share

$$anonymous$$eanwhile can you help me?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DaveA · Feb 14, 2011 at 07:57 PM

You will fire OnTriggerEnter in the frame when that happens. You will get GetKeyDown in the frame that happens. In your code, both would have to happen in the same frame for this to load the level. Yu could use Input.GetKey("e") instead, it will tell you if the 'e' key is down when the trigger is entered, but sounds like you want the reverse, so use OnTriggerStay instead, which will be called all frames you stand near the door. Then Input.GetKeyDown will go true when the 'e' key is hit.

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 Moltvatch · Feb 14, 2011 at 08:43 PM 0
Share

thank you, but that doesnt work.

not what you told me but the whole script. I put "ontriggerstay" and you are right that's the effect I wanted.

But when i press the '"e" key in front of the door nothing happens.

Why?

To make it more simple, you've got a FPS chara controller(ccapsule) and a door.

I just need a script, to teleport the capsule on another scene, and in a specific position when I press "e" in front of it.

That's all.

Why nobody can help me do that? it something as simple as 1+1 for someone who knows scripts.

avatar image Moltvatch · Feb 15, 2011 at 12:28 PM 0
Share

thank you so much!

avatar image DaveA · Feb 15, 2011 at 06:01 PM 0
Share

I don't think you transport it to another scene, unless you mean to another part of the same scene. If it's to another part of the same scene, you set the transform.position of the object to the new spot. If it's in a completely different scene, you'll be loading a whole new scene right? If there is only one place to spawn there (your teleport destination), then set the controller in THAT scene to that spot. If on the other hand you will have multiple possible destinations in that new scene, and you want to pick it, read on:

avatar image DaveA · Feb 15, 2011 at 06:05 PM 0
Share

You'll need to have a piece of data persist across the scene load. You can do this by using PlayerPrefs, or Object.DontDestroyOnLoad. In the latter, you could do that on the capsule, but probably better just make an string var like 'destination' which would be the name of an object in the new scene. When the scene loads, a script there would have a Start or Awake function that would read that string, look for that object, get it's transform.position, and set the capsule position to that.

avatar image
0

Answer by Shatterstar · Jun 11, 2014 at 01:59 PM

I think you have to write a function inside your camera script that teleports your camera also.

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

1 Person is following this question.

avatar image

Related Questions

Moving gameobject relative to resolution 1 Answer

Door open/load level java script troubles 1 Answer

help with door script! 3 Answers

How to find the comparative object's position compare with game screen? 1 Answer

Animation clip does not exist? 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