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 Bram 1 · Dec 22, 2010 at 03:14 PM · colliderplayerhitdead

how to move the player away when it's hit

Hello, i'm trying to make a tank game. and it just won't work for the player to die. I wanted to test it by tagging the enemy projectile. but the projectile disappears when it collided to the tank and a huge explosion came.. but i didn't "die" are there any other ways to do this?? here is my code

private var dead = false;

function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.gameObject.tag == "rocket") { dead = true; }

}

function LateUpdate() { if(dead) {

transform.position = Vector3(100,100,100); dead = false; } }

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
2

Answer by Berenger · Dec 22, 2010 at 03:54 PM

If your player die, you have to think of what's going to happen next. Is it going to respawn elsewhere, or displaying a game over splash screen ? The destruction seems unlikely, you don't need it either way.

What happen if you do a Debug.Log( hit.gameObject.tag ); in OnControllerColliderHit? Anyway for your tests, I'm not sure playing with your player transformation is a good idea, better to do a CharacterController.Move or something like that.

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 Bram 1 · Dec 22, 2010 at 04:01 PM 0
Share

I wanted to check if something happens when the projectile collides with my tank. And i checked it by setting the die to move to another place. so i knew ok. so something is happening. then i could think about what i want to do with it. But here is the Problem: Nothing happens when they collide with each other,

so i want to know. is there any other way for my player to die.

avatar image
0

Answer by JGeorge · Dec 22, 2010 at 03:19 PM

What do you mean by die? Do you want the tank object to be destroyed, etc. We need more information to help you.

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 Bram 1 · Dec 22, 2010 at 03:21 PM

yes i want the tank to be destroyed. but the tank is the player.. i control it what do you need to know more ?

the moving to 100, 100, 100 was just to test if the script worked correctly

is there a way to destroy it when it hit a explosion ?

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 Jesus_Freak · Dec 22, 2010 at 04:00 PM 0
Share

if you're gonna say something like this, in the future, just add a comment under the answer to tell them something. only answer if you know tha answer.

avatar image Marks98 · Feb 10, 2018 at 10:31 AM 0
Share

I have the same problem. In previous versions of unity work perfectly. These transform. position = new Vector3(0,0,0); But now if put this code in to the player collision detection it not working.

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

Accesing Player colliderhit with other gameobject? 2 Answers

3D Building Object collider not working 0 Answers

Jet bike is not moving forward. 0 Answers

Raycast Destroy(hit.collider.gameObject); (Still need help) 1 Answer

How to make player go through object but can't go back 3 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