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 artsdcs · Jun 06, 2012 at 05:32 PM · resetteleportrestart

restart when dead

how can i make it so that when my player touches a collider with the tag Restart he teleports back to the start of the scene?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by warddav16 · Jun 06, 2012 at 07:32 PM

Vector3 StartingPosition; Vector3 StartingForwardPosition;

void Start() {

StartingPosition = transform.position; StartingForwardPosition = transform.forward; }

//If its a collider, use OnCollisionEnter //If its a trigger, use OnTriggerEnter(Collider coll) void OnCollisionEnter(Collision coll) { transform.position = StartingPosition; transform.forward = StartingForwardPosition; }

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
0

Answer by kolban · Jun 06, 2012 at 06:33 PM

To answer your question, let us consider two separate aspects of the game. The first is "position". Every game object (including your player) has a position in the 3D world. The position is given by a Vector3 which contains x, y and z values. If we assume that the start of the scene is at 0,0,0 then to "teleport" back to the start, you would execute the following code:

 transform.position = Vector3(0,0,0);

It is assumed that this code is executed in the context of your player gameObject.

The next part of your question is detecting when a player collides with an object.

See the following:

http://unity3d.com/support/documentation/Components/class-BoxCollider.html

At a high level, your will flag your Collider component as a "Trigger". When your player game object enters the trigger, the OnTriggerEnter() callback on a script attached to your collided object will be called. This will serve as the indication that your player needs to be teleported back to the start of the scene using the transform.position technique described previously.

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 artsdcs · Jun 06, 2012 at 06:59 PM 0
Share

is it also possible to make it so that this happens when you touch partcile colliders?

thank you

avatar image kolban · Jun 06, 2012 at 08:18 PM 0
Share

Apparently the answer is yes. I searched and found:

http://answers.unity3d.com/questions/16239/particle-colliders.html

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Reset The Scene ? 2 Answers

How to check where a player is looking 2 Answers

Teleport enemy after player collides with an object? 0 Answers

i need to know how to make a menu 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