So far my script is below. I am attempting to create another Collider part to the script, I am attempting to make it so when you collide with Lava, which has a Tag named lava, the player will die. However, I can't get it to call for the die function and I also can't use OnTriggerEnter(collider,other)
as it gives me an error.
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
// Player Movement Start
{
public float speed;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement * speed);
}
//End of Player Movement Script
//Pickups Script
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Pick Up"))
{
other.gameObject.SetActive(false);
}
}
//End of Pickups Script
//Health and Death Script
public float health;
public GameObject Ragdoll;
public void TakeDamage(float dmg){
health -= dmg;
if (health <= 0) {
Die();
}
}
public void Die() {
Application.LoadLevel(Application.loadedLevel);
}
}
//End of Health and Death script