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 opbyen · Mar 04, 2013 at 12:30 PM · javascriptcollisiondamagefire

Damage on collision problems...

I have this problem, I am trying to make a fire particle damage my player.

I have no clue what´s wrong every forum with people having the same problem make it work but when I use the same solution, nothing happens.

That´s the primary problem, not that it is too quick to damage or something like that, seriously nothing fucking happens.

This is the Damage on collision script (js) (tried to make it as basic as possible)


var damage = 10;

function OnCollisionEnter (collision : Collision)

{

collision.gameObject.SendMessageUpwards("PlayerDamage", damage); Debug.Log ("Collision entered");

}


and this is the my PlayerDamage script (All credit to Armed Unity)


/** Script written by OMA [www.armedunity.com] */

@script ExecuteInEditMode()

var hitPoints : float; var regenerationSkill : int; var shieldSkill : int; var painSound : AudioClip; var die : AudioClip; var deadReplacement : Transform; var mySkin : GUISkin; var explShake : GameObject; private var radar : GameObject; var maxHitPoints : int; var damageTexture : Texture; private var time : float = 0.0; private var alpha : float; private var callFunction : boolean = false; private var scoreManager : ScoreManager;

function Start(){ maxHitPoints = hitPoints; alpha = 0; }

function Update(){ if (time > 0){ time -= Time.deltaTime; } alpha = time; if( hitPoints <= maxHitPoints){ hitPoints += Time.deltaTime * regenerationSkill; }

 if( hitPoints > maxHitPoints){
     var convertToScore : float = hitPoints - maxHitPoints;
     scoreManager = gameObject.Find("ScoreManager").GetComponent("ScoreManager");
     scoreManager.addScore(convertToScore);
     hitPoints = maxHitPoints;
 }    

}

function PlayerDamage (damage : int) { if (hitPoints < 0.0) return;

 damage -= shieldSkill;
 
 if(damage > 0){
     // Apply damage
     hitPoints -= damage;
     audio.PlayOneShot(painSound, 1.0 / audio.volume);
     time = 2.0;        
 

     // Are we dead?
     if (hitPoints <= 0.0)
     Die();
 }else{
     damage = 0;
 }    

}

//Picking up MedicKit function Medic (medic : int){

 hitPoints += medic;
 
 if(hitPoints > maxHitPoints)
 hitPoints = maxHitPoints;

}

function Die () { if(callFunction) return; callFunction = true;

 if (die && deadReplacement)
     AudioSource.PlayClipAtPoint(die, transform.position);

 // Disable all script behaviours (Essentially deactivating player control)
 var coms : Component[] = GetComponentsInChildren(MonoBehaviour);
 for (var b in coms) {
     var p : MonoBehaviour = b as MonoBehaviour;
     if (p)
         p.enabled = false;
 }
 // Disable all renderers
 var gos = GetComponentsInChildren(Renderer);
 for( var go : Renderer in gos){
     go.enabled = false;

 }
 if(radar != null){
     radar = gameObject.FindWithTag("Radar");
     radar.gameObject.SetActive(false);
 }
 Instantiate(deadReplacement, transform.position, transform.rotation);
 yield WaitForSeconds(4.5);
 //Destroy (transform.root.gameObject);
 LevelLoadFade.FadeAndLoadLevel(Application.loadedLevel, Color.black, 2.0);

}

function OnGUI () { GUI.skin = mySkin; var style1 = mySkin.customStyles[0]; GUI.Label (Rect(40, Screen.height - 50,60,60)," Health: "); GUI.Label (Rect(100, Screen.height - 50,60,60),"" +hitPoints.ToString("F0"), style1);

 GUI.color = Color(1.0, 1.0, 1.0, alpha); //Color (r,g,b,a)
 GUI.DrawTexture(new Rect(0,0,Screen.width, Screen.height), damageTexture);

}

function Exploasion(){ explShake.animation.Play("exploasion"); }


I don´t know what is wrong and the console in unity doesn´t find any errors,

Hope someone can help me!

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 Fattie · Mar 04, 2013 at 12:30 PM 0
Share

it's very hard to get EXTRE$$anonymous$$ELY LONG questions answered

0 Replies

· Add your reply
  • Sort: 

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

11 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

Related Questions

Multiple Cars not working 1 Answer

Analysing player metrics help 0 Answers

Check if an object is at a relative position? 2 Answers

Player take damage on collision with AI 1 Answer

Character controller mess up damage 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