- Home /
Health system 2d
using UnityEngine;
using System.Collections;
public class GameManager : MonoBehaviour {
//Player Life
public Texture playersHealthTexture;
//Control Screen Position of Texture
public float screenPositionX;
public float screenPositionY;
//Controls Icon Size on Screen
public float iconSizeX = 25;
public float iconSizeY = 25;
//Starting lives
public int playersHealth = 5;
void Ongui(){
//Controls Players Health Textures
for(int h = 0; h < playersHealth; h++){
GUI.DrawTexture(new Rect(screenPositionX + (h * iconSizeX), screenPositionY, iconSizeX, iconSizeY), playersHealthTexture,ScaleMode.ScaleToFit, true, 0);
}
}
}
Thats my code in #c but when i hit play theres no errors but my health texture isn't showing up when it on??? What should i do i want a health system that shows 5 of my hearth health textures and 1 is taken away every time he dies.
Comment
Answer by valkyie_of_the_rockies · Mar 04, 2016 at 09:11 AM
It's probably because you didn't declare any values for screenPositionX and screenPositionY
Your answer
Follow this Question
Related Questions
Equivelant of GUI.DrawSprite() ? 0 Answers
Simple heart system using new UI features? 0 Answers
Health bar by percentage? (not drawing a box) 4 Answers
Can anyone identify the error with my GUITexture code? 1 Answer
The Game Over creating with audio? 1 Answer