So im trying to use a script for an enemy to attack. However the enemy falls through the floor. I there a problem with the script so far or is it the actual enemy entity?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AttackPlayer : MonoBehaviour {
private Transform player;
// Use this for initialization
void Start ()
{
player = GameObject.Find("Player").GetComponent<Transform>();
}
// Update is called once per frame
void Update ()
{
transform.LookAt(player);
transform.position = Vector3.MoveTowards(transform.position, player.position, 2*Time.deltaTime);
}
void OnTriggerEnter(Collider other)
{
if(other.GetComponent<Collider>().name == "Player")
{
Application.LoadLevel(0);
}
}
}