Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
3
Question by GreatCorn · Apr 09, 2019 at 08:03 PM · transformplayerissuecoordinatesstandard assets

Can't change player's position

I have a simple script

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class TeleportBack : MonoBehaviour
 {
      public Vector3 teleportPosition;
      
      void OnTriggerStay(Collider other){
           if(other.gameObject.tag == "Player") {
                other.transform.Translate(teleportPosition, Space.World);
                Debug.Log("Teleported Player back");
           }
      }
 }

It works and all, but the StandardAssets FPSController only gets teleported "visually" to the position while on the collider trigger(in editor the coordinates also change only visually and in game the camera stays on the "visual" coordinates). When walking out of the trigger(with the physical coordinates) player visually goes back to his physical coordinates. Any ideas?

Comment
Add comment · Show 1
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 GreatCorn · Apr 09, 2019 at 08:09 PM 0
Share

A little more details to any of those who'd like to help. The script spams the Debug.Log infinitely while the player is on the trigger with his physical/real coordinates.

3 Replies

· Add your reply
  • Sort: 
avatar image
9

Answer by GreatCorn · Apr 09, 2019 at 08:31 PM

Figured out I could try disabling the CharacterController before the Translate function and then enable it right after that. Worked for now.

Comment
Add comment · Show 3 · 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 heartgg · Mar 29, 2020 at 12:36 AM 0
Share

Thank you! I was stuck on figuring stuff with teleporting the player for about 2 hours and then I stumbled upon your post.

Do you know why disabling the character controller works?

avatar image loconeko73 · Oct 29, 2020 at 11:55 PM 0
Share

Thanks a bunch, that dug me out of my hole. I was working on a Save/Load function and couldn't understand why my properly saved position was not updating the character. Just had to disable the character controller first

 cc.enabled = false;
 cc.transform.position = new Vector3(position[0] , position[1] , position[2]);
 cc.enabled = true;
avatar image martinezfrancoleonardo · Oct 09, 2021 at 01:15 PM 0
Share

Thank you so much! I spent a whole day trying to move a player to a checkpoint after they're dead, but it seldom failed so it respawned in the same position they died. After reading this, I got it to work by first diabling the CharacterController, moving the player's gameobject and the re-enabling the CharacterController.

Thanks!

avatar image
4

Answer by NiGodfrin · Sep 08, 2020 at 10:44 PM

Hi, I'm a little bit later but I think it's just because Unity don't authorize weird position transition like teleportation by default. What you can simply do, is going to Player Setting -> Physics and enable Auto Sync Transforms. alt text


capture.png (57.6 kB)
Comment
Add comment · Show 3 · 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 cs120319992 · Apr 11, 2019 at 09:24 AM

 other.transform.position = teleportPosition;
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 GreatCorn · Apr 25, 2019 at 11:47 AM 0
Share

I have already tried that. Without doing stuff to the CharacterContoller nothing worked for me.

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

159 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

Related Questions

Teleporting Player to a point using box colliders 1 Answer

how to make a character resume after going into a random battle? 1 Answer

look at player when button pressed 1 Answer

Writing my own enter/exit car - need help. 2 Answers

Convert Canvas Space point to local space of a rotated rect? 2 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