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 allesisda · Mar 18, 2011 at 12:17 PM · respawnspawnpointsdifferent

Respawn player at different Spawnpoints

Hi there! I'm trying to make my player respawn at a fixed spawnpoint. I want to have different spawnpoints along my level... here is my question: how can i pick up the cordinates of a taged gameobject? thanks

here is my script:

var spawnp=0;

function dead() { if(spawnp == 0) { transform.position.x = 0; transform.position.y = 12; transform.position.z = -9; transform.rotation.y = 0; } if(spawnp == 1) { transform.position.x = 0; transform.position.y = 26.0515; transform.position.z = 121.4297; transform.rotation.y = 0;

 }
 }
         Healthcontrol.LIVES -=1;

}

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by poncho · Mar 18, 2011 at 02:35 PM

to get the coordinates of a gameobject's transform you need its position property like

GameObject.Find("MyObject").Transform.Position

the Position property is a Vector3 object

hope this is the answer you are looking for

Comment
Add comment · Show 2 · 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 allesisda · Mar 18, 2011 at 10:49 PM 0
Share

thanks, but it didn't work:

Assets/scripts/respawnPlayer.js(68,49): BCE0034: Expressions in statements must only be executed for their side-effects.

avatar image poncho · Mar 22, 2011 at 02:35 PM 0
Share

what i meant was, to put your info in that order, like if(spawnp ==0){GameObject.Find("YourTransformTo$$anonymous$$ove").Transform.Position = new Vector3(0,12,-9);} if(spawnp ==1){GameObject.Find("YourTransformTo$$anonymous$$ove").Transform.Position = new Vector3(0,26.0515,121.4297);} note that the name "YourTransformTo$$anonymous$$ove" should be replaced for the name of the transform you want to change its position like cube1, hero, mainchar or the name you used, i thought the answer i gave, was intuitive, my bad.

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

No one has followed this question yet.

Related Questions

Why doesnt my respawn script work? 2 Answers

Multiple spawn points without spawning in the same place. 2 Answers

Different spawn points from different scenes ? [Solved] 2 Answers

Retrieve the exact spawn point when I destroy its pickup 2 Answers

Stop Object from deleting HELP ME!!!!!!!!!!!! 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