Quantcast
Channel: Latest Questions by Kenshen112
Viewing all articles
Browse latest Browse all 16

Sorry Me again :P Error CS0131

$
0
0
So i need more help with my health script I'm trying to add a game over Player Health using UnityEngine; using System.Collections; public class PlayerHealth : MonoBehaviour { // Use this for initialization int Health = 100; public void Start () { } // Update is called once per frame void Update () { if (Health == 0) { Application.LoadLevel("GameOver"); } } void OnGUI () { } public void ChangeHealth(int howMuch){ this.Health += howMuch; } } Enemy using UnityEngine; using System.Collections; public class Enemy : MonoBehaviour { // Use this for initialization public void OnCollisionEnter(Collision collision) { PlayerHealth playerHealth = GetComponent(); if (collision.gameObject.tag == "Player") { if(playerHealth == null) return; // Get out. while(playerHealth.ChangeHealth = 100) { playerHealth.ChangeHealth(-10); } } } // Update is called once per frame void Update () { } } In my Enemy script I've added a while loop to Loop health damage each time i collide with Enemy object in player health game over condition If i ask a lot of questions here I'm sorry I've always learn from experience any help would be appreciated :).

Viewing all articles
Browse latest Browse all 16

Trending Articles