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 m2graphics · May 11, 2015 at 05:51 AM · c#unity 5triggercarrespawn

Car won't return to respawn point after hitting a trigger

I am making a simple car game and want the car to reset to a respawn point if the user hits a wall. Using the UnityStandardAssets FPS or 3rd person controllers, the respawn script works fine, but not with the car model I am trying to use or the UnityStandardAssets-Vehicles Car. The wall has 'convex' and 'isTrigger' checked, and has the respawn script applied. The car has a rigidbody on the main node, as well as a box collider in the general shape of the car.

Here is the respawn script:

 using UnityEngine;
 using System.Collections;
 
 public class RespawnScript : MonoBehaviour {
     
     //Place holder for the spawn point
     public Transform respawnPoint;
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
     
     }
     
     //This fires off when the player hits the wall

     void OnTriggerEnter(Collider other)
     {
         print("Wall Hit");
     
         //Moves the player to the spawn point
         other.gameObject.transform.position = respawnPoint.position;
     }
 }
 

I see the 'Wall Hit' message printed when the car drives into the wall, so I know the car and wall are communicating. I just can't get the script to properly respawn the car. If anyone has any easier solutions, I would gladly try them.

Comment
Add comment · Show 1
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 Umresh · May 11, 2015 at 06:19 AM 0
Share

How are you moving your car I mean using rigidbody or using transform. If you are using rigidbody to move your car script works fine.

2 Replies

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

Answer by m2graphics · May 13, 2015 at 07:42 PM

I was able to solve this by adding public GameObject Player; to the beginning of the script, and then replacing other.gameObject.transform.position with player.transform.position.

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 alok-kr-029 · May 11, 2015 at 06:22 AM

Your problem is not very clear ,what I am understanding is you are having problem respwaning the car although the your trigger is working fine and "wall hit" get printed .

in place of position try using localPosition. hope it might work .

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Guides or Tutorials for a Very Basic Enemy AI? [Unity 5] 1 Answer

Multiplayer Respawning Problems 0 Answers

EventTrigger PointerEnter 1 Answer

Car trembling when reaching a certain speed 1 Answer

Multiplayer Respawning Problems 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