So when my health goes down I want the guiTexture to scale down in the x value just like a health bar. But I get errors when I try to get this to work. Can I keep it this way or do I have to change it?
Assets/Adventure Game/MaleCharacterPack/VincentSword_Control.cs(21,39): error CS1612: Cannot modify a value type return value of `UnityEngine.GUITexture.pixelInset’. Consider storing the value in a temporary variable
using UnityEngine;
using System.Collections;
public class VincentSword_Control : MonoBehaviour {
public int health;
public GameObject healthTexture;
private bool isHit;
private bool canPickupHealth;
private bool isDead;
// Use this for initialization
void Start () {
health = 100;
isHit = false;
isDead = false;
}
// Update is called once per frame
void Update () {
if(health == 100){
healthTexture.pixelInset.x = 200.0f;
}if(health == 95){
healthTexture.pixelInset.x = 190.0f;
}if(health == 90){
healthTexture.pixelInset.x = 180.0f;
}if(health == 85){
healthTexture.pixelInset.x = 170.0f;
}if(health == 80){
healthTexture.pixelInset.x= 160.0f;
}if(health == 75){
healthTexture.pixelInset.x = 150.0f;
}if(health == 70){
healthTexture.pixelInset.x = 140.0f;
}if(health == 65){
healthTexture.pixelInset.x = 130.0f;
}if(health == 60){
healthTexture.pixelInset.x = 120.0f;
}if(health == 55){
healthTexture.pixelInset.x = 110.0f;
}if(health == 50){
healthTexture.pixelInset.x = 100.0f;
}if(health == 45){
healthTexture.pixelInset.x = 90.0f;
}if(health == 40){
healthTexture.pixelInset.x = 80.0f;
}if(health == 35){
healthTexture.pixelInset.x = 70.0f;
}if(health == 30){
healthTexture.pixelInset.x= 60.0f;
}if(health == 25){
healthTexture.pixelInset.x = 50.0f;
}if(health == 20){
healthTexture.pixelInset.x = 40.0f;
}if(health == 15){
healthTexture.pixelInset.x= 30.0f;
}if(health == 10){
healthTexture.pixelInset.x = 20.0f;
}if(health == 0){
healthTexture.pixelInset.x= 5.0f;
}
}
void OnTrigger(Collider other)
{
if(other.gameObject.tag == "Enemy")
{
health = health - 5;
}
}
}
Assets/Adventure Game/MaleCharacterPack/VincentSword_Control.cs(21,39): error CS1612: Cannot modify a value type return value of `UnityEngine.GUITexture.pixelInset’. Consider storing the value in a temporary variable