Death on Lava collision

Translation: I’m not a really good programmer and I’m trying to make my character ‘die’ when he falls on lava. How would I go forth doing this?

Original Message:

i am making a game where if the character touches the lava he dies...now i am horrible...HORRIBLE with scripting for right now so i really need help with how to do this...PLEASE HELP!!!

Batman, I think you're just too old for it, buddy.

–

Geez, when I read that title I thought someone was gonna get killed!!!!!!!!!!!!!!!!!!!!!!

–

What I'm saying is, I remember when you were really good at using your batputer. It's time to move on to cursing the kids on the Wayne Manor lawn, old-timer.

–

No, I'm not going to sit by and watch you fall apart. You used to swear you would never take a human life. Now, look at the kinds of threads you're posting! I recommend working through some battutorials.

–

@wstelzle in the player settings

–

2 Answers

2

// A grenade // - instantiates a explosion prefab when hitting a surface // - then destroys itself

 var explosionPrefab : Transform;

  function OnCollisionEnter(collision : Collision) {
 // Rotate the object so that the y-axis faces along the normal of the surface
    var contact : ContactPoint = collision.contacts[0];
    var rot : Quaternion = Quaternion.FromToRotation(Vector3.up, contact.normal);
    var pos : Vector3 = contact.point;
    Instantiate(explosionPrefab, pos, rot);
    // Destroy the projectile
    Destroy (gameObject);
      }

http://unity3d.com/support/documentation/ScriptReference/Collider.OnCollisionEnter.html

http://unity3d.com/support/documentation/ScriptReference/Object.Destroy.html

@Jaidan Thanks for your quick reply. I found it. It was already set to that first setting FAT ​ (ARMv 7 + x86) so now I wonder (because I came across a few posts) what are your Graphics API settings? Thanks

–

If you have the code in place for your character dieing, you only got to call that function.

So basically you would create something like:

private void CheckDeath(int Hp)     
 {
 
 if (hp = 0)    
 { 
    -execute wathever code you have for dieing, could be a message, together with a red overlay on the screen. And code to revive-    
 }
 }

And then for the touching itself, you would need a collider, but I haven’t worked with those yet. (The basics should be in the link Robert posted.)

Just wondering, does the Graphics API settings have a part in causing this error?

–