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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Steve L · Feb 09, 2015 at 02:38 AM · 2dmovementtransformplayerteleport

How can I make a collision sensitive teleporter for a 2D game #c

alt text

Hello Unity folks,

I am trying to create a Teleporter which is able to feel the location of collision and transform the place of impact to the same place on the second exit teleporter (Like the 3d plane collider). I have tried multiple scripts and tutorials but I cannot come up with any solution. Most of the tutorials were meant for 3d projects.

The teleporter pad is stretched from left to right. The collision will be from under as my player is floating upwards.

I have tried to use the 3d plane collider but got an error because I couldn't use it with the 2d physics engine of unity.

I appreciate any help as this is really a struggle for me.

With kind regards and thanks in advance.

screen-shot-2015-02-09-at-32117-am.png (127.7 kB)
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 AlwaysSunny · Feb 09, 2015 at 01:09 AM 0
Share

How about some pictures or something? Screenshots? I think I get what you're asking, but without knowing/seeing more to be certain, I don't want to waste our time.

If I understand, you can use your collision event's contacts. On collision, transform the first contact into local space, set the teleported object's position to the other pad's position + the transformed point-of-contact.

http://docs.unity3d.com/ScriptReference/Collision2D-contacts.html

avatar image Steve L · Feb 09, 2015 at 02:32 AM 0
Share

I have added a screenshot to be more clear about the problem. Is this clear enough?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by AlwaysSunny · Feb 09, 2015 at 04:15 AM

I think so. Screenshots / diagrams always help. If these pairs-of-teleporters always share the same size and orientation, the easiest solution might be...

 //OnTriggerEnter   
 Vector3 offset = object.position - teleporterA.position;
 object.position = teleporterB.position + offset;

Might have the offset backwards, I'm a little decaffeinated. If teleporters didn't share orientations, things might get interesting. Lemme know if this works out, and good luck,

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 Steve L · Feb 09, 2015 at 02:56 PM 0
Share
 using UnityEngine;
 using System.Collections;
 
 public class Teleporter : $$anonymous$$onoBehaviour {
     public object TeleportTo;
 
     
     // Use this for initialization
     void Start () {
     }
     
     // Update is called once per frame
     void Update () {
     }
     
     void OnTriggerEnter (Collider other) {
       
         Vector3 offset = object.position - teleporterA.position;
         object.position = teleporterB.position + offset;
 
     }
 }

Something like this? I am missing some connections because I get a lot of red references. I am not really experienced with scripting I am a beginner, sorry :p

alt text

screen-shot-2015-02-09-at-35450-pm.png (120.0 kB)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Player movement boudaries in 2D 1 Answer

Player stops moving upon collision 0 Answers

Problems with the movement of the player 1 Answer

Character rotation and move to mouse click point with speed 0 Answers

How can I move the character like 2D games? 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