Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Game Mewarnai Tutorial
Thu Mar 23, 2017 10:21 am by kamil

» [ASK HELP] Slide informasi di augmented reality
Tue Jan 03, 2017 8:58 pm by Briyan_ap

» ASK cara klik dan memunculkan informasi
Tue Jan 03, 2017 8:54 pm by Briyan_ap

» [Ask] mengubah game PC menjadi game Android
Tue Jan 03, 2017 10:57 am by NiethaChan

» Virtualisasi suatu Gedung mengunakan unity3D + google seketchUP
Sat Dec 31, 2016 1:06 am by zeepank

» Minta Tolong, slideshow ngga muncul saat object di klik
Tue Dec 27, 2016 12:53 pm by Briyan_ap

» tolong dong lagi bikin button rotate tp button ga keluar
Wed Dec 21, 2016 1:15 pm by Lita Misae

» algoritma Minimax/negascout buat checkers
Wed Nov 30, 2016 1:51 am by ardiansa

» screenshot
Wed Nov 16, 2016 10:15 pm by azhari

Statistic

Script Destroy GameObject With Health

View previous topic View next topic Go down

Script Destroy GameObject With Health

Post  KzRaItoN on Mon Sep 24, 2012 12:52 pm

Sedikit Script Destroy Object Bagi Yang Mau Buat Game (Beserta Health)
Thanks To : Ilham Hasymi Effendi & BurgZergArcade

Nih Scriptnya(Unity 3d) (C# Script) :
using UnityEngine;
using System.Collections;

public class EnemyHealth : MonoBehaviour {
public int maxHealth = 100;
public int curHealth = 100;
public int health;

public float healthBarLength;

// Use this for initialization
void Start () {
healthBarLength = Screen.width / 2;
}

// Update is called once per frame
void Update () {
AddjustCurrentHealth(0);
}

void OnGUI() {
GUI.Box(new Rect(10, 40, healthBarLength, 20), curHealth + "/" + maxHealth);
}

public void AddjustCurrentHealth(int adj) {
curHealth += adj;

if(curHealth < 0)
curHealth = 0;

if(curHealth > maxHealth)
curHealth = maxHealth;

if(maxHealth < 1)
maxHealth = 1;

healthBarLength = (Screen.width / 2) * (curHealth / (float)maxHealth);

if(curHealth <= 0){
Destroy(gameObject);
}
}
}

Semoga Membantu Ya Scriptnya, Hehehehehe Very Happy
avatar
KzRaItoN
Unity3D Newbie
Unity3D Newbie

Posts : 19
Points : 31
Reputation : 0
Join date : 2012-09-05

View user profile

Back to top Go down

Re: Script Destroy GameObject With Health

Post  trutions on Thu Sep 27, 2012 11:27 am

wah...setelah sekian lama ane nongkron di sini.,... akhirnya ada mastah yang posting.... Very Happy
avatar
trutions
Unity3D Newbie
Unity3D Newbie

Posts : 6
Points : 11
Reputation : 3
Join date : 2012-09-21

View user profile

Back to top Go down

Re: Script Destroy GameObject With Health

Post  KzRaItoN on Thu Sep 27, 2012 1:42 pm

trutions wrote:wah...setelah sekian lama ane nongkron di sini.,... akhirnya ada mastah yang posting.... Very Happy
hehehehehe, Iya Nih, Thanks ya dah mampir Very Happy
avatar
KzRaItoN
Unity3D Newbie
Unity3D Newbie

Posts : 19
Points : 31
Reputation : 0
Join date : 2012-09-05

View user profile

Back to top Go down

Re: Script Destroy GameObject With Health

Post  aanimation on Fri Mar 21, 2014 2:46 pm

setidaknya setiap baris yg diketik juga dipahami, hayo semangat  bounce 
avatar
aanimation
Unity3D Newbie
Unity3D Newbie

Posts : 47
Points : 50
Reputation : 3
Join date : 2014-03-21
Age : 32
Location : Jogjakarta

View user profile https://dl.dropboxusercontent.com/u/25548837/majaGame/version5.h

Back to top Go down

Re: Script Destroy GameObject With Health

Post  kikysikancil on Fri Jun 06, 2014 2:23 pm

Biar kata postingan udah lewat 2 tahun juga mesti tetap di apresiasi. Good job, master!
avatar
kikysikancil
Unity3D Developer
Unity3D Developer

Posts : 178
Points : 197
Reputation : 15
Join date : 2014-06-06
Age : 35
Location : Bandung

View user profile http://id.tutorialnetworks.com

Back to top Go down

Re: Script Destroy GameObject With Health

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum