Can u help me ?
First error
Assets\Scripts\LifeSystem.cs(4,19): error CS0234: The type or namespace name ‘UI’ does not exist in the namespace ‘UnityEngine’ (are you missing an assembly reference?)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LifeSystem : MonoBehaviour
{
player player;
public bool dead;
public int life;
public int maxLife;
public Image [ ] heart;
public Sprite Full;
public Sprite Empty;
// Start is called before the first frame update
void Start()
{
player = GetComponent();
}
// Update is called once per frame
void Update()
{
HealthLogic();
DeadState();
}
void HealthLogic()
{
if(life > maxLife)
{
life = maxLife;
}
for (int i = 0; i < heart.Length; i++)
{
if(i< life)
{
heart*.sprite = Full;*
}
else
{
heart*.sprite = Empty;*
}
if(i < maxLife)
{
heart*.enabled = true;*
}
else
{
heart*.enabled = false;*
}
}
}
void DeadState()
{
if(life <= 0)
{
dead = true;
player.anim.SetBool(“dead”,dead);
GetComponent().enabled = false;
Destroy(gameObject, 1.0f);
}
}
}
Second Error
Assets\Scripts\PlayerLogic.cs(4,19): error CS0234: The type or namespace name ‘UI’ does not exist in the namespace ‘UnityEngine’ (are you missing an assembly reference?)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class player : MonoBehaviour
{
public float Speed;
public float JumpForce;
public bool isJumping;
public bool doubleJumping;
private Rigidbody2D rig;
public Animator anim;
private Vector3 respawnPoint;
public GameObject fallDetector;
public GameObject shotProject;
public Transform Weapon;
private bool shot;
public float shotForce;
// Start is called before the first frame update
void Start()
{
rig = GetComponent();
anim = GetComponent();
respawnPoint = transform.position;
}
// Update is called once per frame
void Update()
{
Move();
Jump();
fallDetector.transform.position = new Vector2(transform.position.x, fallDetector.transform.position.y);
shot = Input.GetButtonDown(“Fire”);
}
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.tag == “FallDetector”)
{
transform.position = respawnPoint;
}
}
void Move()
{
Vector3 movement = new Vector3(Input.GetAxis(“Horizontal”), 0f, 0f);
transform.position += movement * Time.deltaTime * Speed;
if(Input.GetAxis(“Horizontal”) > 0f)
{
anim.SetBool(“walk”, true);
transform.eulerAngles = new Vector3(0f,0f,0f);
}
if(Input.GetAxis(“Horizontal”) < 0f)
{
anim.SetBool(“walk”, true);
transform.eulerAngles = new Vector3(0f,180f,0f);
}
if(Input.GetAxis(“Horizontal”) == 0f)
{
anim.SetBool(“walk”, false);
}
shot = Input.GetButtonDown(“Fire2”);
}
void Jump()
{
if(Input.GetButtonDown(“Jump”))
{
if (!isJumping)
{
rig.AddForce(new Vector2(0f, JumpForce), ForceMode2D.Impulse);
doubleJumping = true;
anim.SetBool(“jump”, true);
}
else
{
if(doubleJumping)
{
rig.AddForce(new Vector2(0f, JumpForce), ForceMode2D.Impulse);
doubleJumping = false;
}
}
}
}
void OnCollisionEnter2D(Collision2D colli)
{
if(colli.gameObject.layer == 8)
{
isJumping = false;
anim.SetBool(“jump”, false);
}
}
void OnCollisionExit2D(Collision2D colli)
{
if(colli.gameObject.layer == 8)
{
isJumping = true;
}
}
private void shooting()
{
if(shot == true)
{
GameObject temp = Instantiate(shotProject);
temp.transform.position = Weapon.position;
temp.GetComponent().velocity = new Vector2(shotForce, 0);
Destroy(temp.gameObject, 3f);
}
}
}
Third Error
Assets\Scripts\LifeSystem.cs(13,12): error CS0246: The type or namespace name ‘Image’ could not be found (are you missing a using directive or an assembly reference?)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LifeSystem : MonoBehaviour
{
player player;
public bool dead;
public int life;
public int maxLife;
public Image [ ] heart;
public Sprite Full;
public Sprite Empty;
// Start is called before the first frame update
void Start()
{
player = GetComponent();
}
// Update is called once per frame
void Update()
{
HealthLogic();
DeadState();
}
void HealthLogic()
{
if(life > maxLife)
{
life = maxLife;
}
for (int i = 0; i < heart.Length; i++)
{
if(i< life)
{
heart*.sprite = Full;*
}
else
{
heart*.sprite = Empty;*
}
if(i < maxLife)
{
heart*.enabled = true;*
}
else
{
heart*.enabled = false;*
}
}
}
void DeadState()
{
if(life <= 0)
{
dead = true;
player.anim.SetBool(“dead”,dead);
GetComponent().enabled = false;
Destroy(gameObject, 1.0f);
}
}
}