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 /
  • Help Room /
avatar image
0
Question by Aunel · Oct 03, 2015 at 08:33 PM · objectteleportspecific position

How teleport gameobject to specific location in c#?

Hi, i teleport object with 2 scripts in JS

1 script , This script is added to a collider

function OnTriggerEnter(hit:Collider) {

  if(hit.gameObject.name == "idolom") 
   {
   gameObject.Find("idmon").SendMessage("React");
    }

}

2 script add to player

function React () { transform.position = Vector3(180, 1.38, 175); }

but i don't know convert to c#

I have seen many scripts to teleport an object to another object, but I have not seen one that teleport an object to specific coordinates that is what interests me.

Thanks

Regards!!

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by BabilinApps · Oct 03, 2015 at 10:29 PM

have to:

  • Change the word function to void (All functions in C# are called voids)

  • add the word "new" to Vector3. (C# requires the use of the word new unless you are deriving from Vector3 like Vector3.Distance

  • Add an "f" to any value that has a decimal or is not an integer (this makes sure that the number is a float and not a double)

       void React () { 
     
         transform.position = new Vector3(180, 1.38f, 175);
     
          }
    
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
avatar image
1

Answer by Vylax · Mar 20, 2016 at 09:04 PM

Script 1 :

 void OnTriggerEnter(Collider hit) {
 
   if(hit.gameObject.name == "idolom") 
    {
    GameObject.Find("idmon").SendMessage("React");
     }
 

script 2 :

 void React () {
 transform.position = new Vector3(180, 1.38f, 175);
 }


and it would work...

you can also use this tool but it's in developpement...

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 noahsaurous · Jan 13, 2021 at 01:18 PM 0
Share

wow, this helped a lot!

avatar image
0

Answer by sebas321123 · Mar 20, 2016 at 08:19 PM

public Transform trasporte;

OnTriggerEnter2D(Collider2D collider ){

collider.gameObject.transform.position = trasporte.position; } so?

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 Vylax · Mar 20, 2016 at 09:08 PM 0
Share

he's game isn't in 2D because for the teleport he use a Vector 3 position so you're code won't work

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

34 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

Related Questions

Random Object Selection 0 Answers

Keep the distance of one object relative to another while changing its size 0 Answers

How can I have multiple sprite objects turned into one sprite object 0 Answers

How to fix problem IndexOutOfRangeException 1 Answer

Can't teleport a car? 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