"enemy code unity" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "enemy code unity" answered properly. Developers are finding an appropriate answer about enemy code unity related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like enemy code unity. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on enemy code unity.
enemy code unity
/*if you want the code to work you need to do this steps
step 1 : you need to have on your enemy a collider.
step 2 : you will need to add the target (what the enemy goind to follow);
step 3 : you will need to add how match health he will have and how fast he will be;
step 4 : add how match damage he will do(if u want to have something that can die you will need to add to it a code the code can be found in this link https://youtu.be/BLfNP4Sc_iA)
step 5 : refrens what you want the enemy to do damage to
and the last thing is to add a death effect(if you want) happy to help!
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour
{
Rigidbody rig;
public GameObject DealDamageTo;
public Transform target;
public GameObject deathEffect;
public int health = 100;
public float speed = 100f;
public int damage = 30;
void Start ()
{
rig = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
Vector3 pos=Vector3.MoveTowards(transform.position,target.position, speed * Time.fixedDeltaTime);
rig.MovePosition(pos);
transform.LookAt(target);
}
public void TakeDamage (int damage)
{
health -= damage;
if (health <= 0)
{
Die();
}
}
void Die ()
{
Instantiate(deathEffect, transform.position, Quaternion.identity);
Destroy(gameObject);
}
void OnTriggerEnter (Collider hitInfo)
{
CanDie DealDamageTo = hitInfo.GetComponent<CanDie>();
if (DealDamageTo != null )
{
DealDamageTo.TakeDamage(damage);
}
}
}
All those coders who are working on the Whatever based application and are stuck on enemy code unity can get a collection of related answers to their query. Programmers need to enter their query on enemy code unity related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about enemy code unity for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of enemy code unity while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "enemy code unity". Visit this developer's friendly online web community, CodeProZone, and get your queries like enemy code unity resolved professionally and stay updated to the latest Whatever updates.