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 Celofa · Jan 07, 2011 at 02:29 PM · gameobjecttriggerpointspecific

How to send a gameobject to a sepcific position in the 3d environment?

I do have a fps character and if this character touches the cube!! it should spawn in a secific point in the 3d environment!

How to code that? How to get to know a specifiv point in my world?

  function OnTriggerEnter (myTrigger : Collider) {
  if(myTrigger.gameObject.name == "First Person Controller"){
  //here should be the script to spawn the fps controller at a specific point!
   }
  }

Celofa

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 Jesse Anders · Jan 07, 2011 at 02:34 PM 0
Share

Do you simply want to move the object to a new location? (I.e. 'teleport' it?) Or do you actually want to spawn (instantiate) a new game object?

avatar image Celofa · Jan 07, 2011 at 02:37 PM 0
Share

i want to move it!! sry!!

avatar image Jesse Anders · Jan 07, 2011 at 03:35 PM 0
Share

Be sure to check one of the answers as 'accepted' so that the question doesn't continue to show up in the 'unanswered' category.

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Jesse Anders · Jan 07, 2011 at 03:06 PM

If you simply want to 'teleport' the other object to a new location, try (untested):

function OnTriggerEnter(other : Collider)
{
    if (other.gameObject.name == "First Person Controller") {
        other.transform.position = ...position you want to teleport to goes here...;
    }
}

Where the target position comes from is up to you.

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 Celofa · Jan 07, 2011 at 03:17 PM 0
Share

yeahh sry for the answer(and not commenting thing)! that works thx!

avatar image
0

Answer by Justin Warner · Jan 07, 2011 at 02:40 PM

var prefab : Transform; var spawn;

function OnTriggerEnter (myTrigger : Collider) { if(myTrigger.gameObject.name == "First Person Controller") { Instantiate (prefab, spawn.transform.position, Quaternion.identity); } }

Drag and drop an empty game object where you want the object to spawn in to the var spawn. And the prefab you want spawned in to the prefab section.

THis is a very common question, search before asking, =).

Hope this helps though, and I did it here, didn't test, so it might need tweaked lol.

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 Justin Warner · Jan 07, 2011 at 02:42 PM 0
Share

Oh, if you want to move it to a location, than I'd suggest using: http://itween.pixelplacement.com/ and http://dkoontz.wordpress.com/2010/10/27/itween-visual-editor/ as you're new.

avatar image Celofa · Jan 07, 2011 at 02:47 PM 0
Share

yeahh ia really really new!!thx

avatar image dione001 · Oct 22, 2013 at 07:17 AM 0
Share

I've tried this code but it says that 'transform' is not a member of 'Object'. What will I do?

avatar image
0

Answer by Celofa · Jan 07, 2011 at 03:05 PM

Itween seems to be a cool library, but i dont need to have the moving process!! I just want the gameobject to be at a other position without any movement animation!!

how to do that?? i hope u understand me!

Celofa

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 Jesse Anders · Jan 07, 2011 at 03:06 PM 0
Share

Be sure to post follow-up questions either as comments or edits to your original post, and not as answers.

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

Delete certain gameobject if it enters the area. 1 Answer

Click on object to activate another object 3 Answers

How to pop up a window with image inside when click a game object? 0 Answers

Can't click gameobject when over another trigger? 1 Answer

Animation playing other object animation 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