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
1
Question by huddy · May 12, 2013 at 12:18 AM · damagehealth

damage health script ineffective, no noticable mistakes

im making yet another slenderman indie, and i am trying to make it so that when slenderman comes in contact with the first person controller it kills him and resets the location, esentially restarting the game. i have my stalking script down but my damage system seems to be ineffective. i have looked at it several times. it is such a simple script yet it remains ineffective. my first person controller contains the rigidbody component while my enemy contains a mesh collider.

  1. var health : int = 100;

private var dead : boolean = false;

var enemyDamage : int = -100;

function OnControllerColliderHit(hit : ControllerColliderHit) {

 if(hit.gameObject.tag == "BloodBoss")
 {
 health +=enemyDamage;
 } 
     

}

function Update () {

 if(health <= 0)
 { 
 dead = true;
 }

 if(dead == true)
 {

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

 }

}

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 TheDarkVoid · May 12, 2013 at 01:00 AM

your adding more health everytime you get hit. you need to do this instead

   if(hit.gameObject.tag == "BloodBoss")
     {
     health -=enemyDamage;
     } 
Comment
Add comment · Show 25 · 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 huddy · May 12, 2013 at 01:26 AM 0
Share

thank you it worked. however my it seems like the first person controller is now ineffective as a result. i cannot move from a stationary position

avatar image huddy · May 12, 2013 at 01:44 AM 0
Share

sorry for being so needy. im still learning! really new to all this, i've been trying to problem solve but it isnt very successful;)

avatar image TheDarkVoid · May 12, 2013 at 02:02 AM 0
Share

is there an error being logged in the console?

avatar image huddy · May 12, 2013 at 02:04 AM 0
Share

no, there's no errors. i just can't move anymore, it's like it eli$$anonymous$$ated the character control motor. i think it has something to do with the vector3 in the script because im remaining stationary at the exact values that i set it at; the values im supposed to respawn at after encountering the enemy, i cannot move from.

avatar image huddy · May 12, 2013 at 02:05 AM 0
Share

i simply cannot even move from the start of the game

Show more comments
avatar image
0

Answer by ricky1996 · May 15, 2013 at 11:54 PM

try adding this script to your players FPS script just after the variables: : private var dead = false;

function OnTriggerEnter(hit : Collider)

{

 if(hit.gameObject.tag=="BloodBoss")

 {
     
     dead = true;
     }

and add this to the end of the script: function LateUpdate()

{

 if(dead)

 {

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

also remember to make a tag called BloodBoss and add it to your slendeman :)

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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Health Regeneration 2 Answers

Damage/Health problem 2 Answers

Weapon Mesh Damage 1 Answer

How to get Enemy to break wall between it and Player. 1 Answer

Player Health Damage 2 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