KARAKTERİN RESPAWN KODU:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameRespawn : MonoBehaviour.
{
public float threshold; //theresold karakterin transformdaki karakterin y ekseninin kısaltma haliymiş.
AttirubesManager AttirubesManager;
// Update is called once per frame.
void FixedUpdate()
{
if (transform.position.y < threshold)
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
SceneManager.LoadScene("DeathScreen");
transform.position = new Vector3(-14f, 1.39f, 16f);
}
}
}
--------------------------------------------------------------------
Düşmanların karaktere hasar verme kodu:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.SceneManagement;
public class AttirubesManager : MonoBehaviour.
{
public int sağlık;
public GameObject player;
public void hasaral(int miktar)
{
sağlık -= miktar;
if (sağlık <=0f)
{
ölüm();
}
}
private void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag == "zombi")
{
hasaral(20);
}
}
void ölüm()
{
Destroy( player );
SceneManager.LoadScene("DeathScreen");
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
transform.position = new Vector3(-14f, 1.39f, 16f);
}
void Update()
{
}
}