• 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 Bogdan003 · Oct 29, 2019 at 07:35 PM · meshteleportteleportingportalportals

Teleportation problem!

I wrote a portal script but whenever i teleport my character it happens to teleport without an arm,how could i connect the body pieces so it teleports completely

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class Teleporter : MonoBehaviour
 {
     public Teleporter Other;
 
     private void OnTriggerStay(Collider other)
     {
         float zPos = transform.worldToLocalMatrix.MultiplyPoint3x4(other.transform.position).z;
 
         if (zPos < 0) Teleport(other.transform);
     }
     private void Teleport(Transform obj)
     {   
         //Position
         Vector3 localPos = transform.worldToLocalMatrix.MultiplyPoint3x4(obj.position);
         localPos = new Vector3(-localPos.x, localPos.y, -localPos.z);
         obj.position = Other.transform.localToWorldMatrix.MultiplyPoint3x4(localPos);
 
         //Rotation
         Quaternion difference = Other.transform.rotation * Quaternion.Inverse(transform.rotation * Quaternion.Euler(0, 180, 0));
         obj.rotation = difference * obj.rotation;
     }
 }
Comment
Add comment · Show 2
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 Reedex · Oct 29, 2019 at 08:02 PM 0
Share

I mean honestly, just briefly looking at the script,...i thought Unity is game engine not a rocket propulsion science. Although.. Unless i am interpreting it badly, you could

 public Transform TeleportEnd;
     
     Void OnTriggerEnter(Collider other)
     {
         other.transform.position = TeleportEnd.position;
         other.transform.rotation = TeleportEnd.rotation;
     }
 

avatar image Bogdan003 Reedex · Oct 29, 2019 at 08:21 PM 0
Share

nah bro this is a portal game like script

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by thomh_unity · Oct 31, 2019 at 10:18 AM

Hi Bogdan003,

If your character has multiple colliders then it's possible you're just moving the transform that the body collider is on.

If the collider is a child of your character's root object then you can use:

 Transform parent = other.transform.parent;
 Teleport(parent); 


If the heirachy is more complex then you can get the root transform for the collider like this:

 Transform root = other.transform.root;
 Teleport(root); 


I hope this helps!

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

130 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

Related Questions

Portal between scenes? 3 Answers

How to keep an Enemy from teleporting outside of a room. 1 Answer

Collision for Amount of Time 1 Answer

making a non walk through portal 2 Answers

Car made of boxes teleports on hard collision 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