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

Enemy script help

$
0
0
So I'm trying to create an enemy that on contact decreases Player health by 10 Player Health script 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 Script 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 () { } } I'm getting Error CS0103: The name Health does not exist in the current context Help?

Viewing all articles
Browse latest Browse all 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>