"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

By Glamorous GoshawkGlamorous Goshawk on Feb 27, 2021
/*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);
        }
        

    }

}

Add Comment

0

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. 

Whatever answers related to "enemy code unity"

View All Whatever queries

Whatever queries related to "enemy code unity"

enemy code unity enemy unity mario rpg enemy attack cheats API.TaskCombatPed(Enemy, Target.Guard, 0, 16); third person shooter camera code unity unity3d indent code in vs code format code in vs code swift_transportexception expected response code 250 but got code "530", with message "530 5.7.1 authentication required " Cannot configure From email address for default email configuration (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID "write code to change the value of a pointer. write code to change the value to which the pointer points" How to beautify code in visual studio code How to align code in visual studio code move gameobject in unity 2d unity using UnityEngine; not working movimento gameobject su unity 3d unity app size what language does unity use unity render text in front of sprite disable script in unity unity dropdown unity controls how to never have 2 same values from random function in unity sprite unity script loading player preferences unity unity get gameobject from hit open link in unity edit>setting>input unity jump unity android back button mathf.clamp unity how to loop an animation in unity decal z fighting unity check whether cursor is on button unity unity can't see button unity rewarded ads unity delegate how to make a car in unity unity scrollrect init pos drawing default serializedproperty unity unity add transparency to shader Get camera position unity detecting a click outside a button unity 2 vscode for unity not working unity desktop path how to keep bool true after runtime unity execute a menu command from script unity unity microgame argumentexception an item has already been added unity set cursor position how to make a menu in unity Unity comment big area out unity timeline how to calculate the angle of a vector in unity unity random array element unity 2019 ArgumentException: Object at index 0 is null unity Unity uncomment big area out second counter unity how to move player in unity 3d array replace unity how to put a wave counter in unity how to make unity build to not be full screen package manager hlapi unity 2020 unity fps camera rotation script 2d explosion unity Unity Photon not able to connect with custom Room unity easing out unity set background image 2d unity rigidbody jump too fast unity change button onclick in script unity default project location unity make sure pressing button doesnt affect underlaying plane how to use codes to unlock games unity unity struct adding a function with a parameter to a button Unity unity audio not playing weapon sway unity detect player stealth unity disable an image in unity unity gui style color button what is the component for sound in unity nickaname and tag unity and pun2 script unity letters apears slowly for navmesh jump component used in unity unity f__mg$cache unity make you fat mum be a chug Saving Data in Unity: Custom Binary Files how to send an error message unity how to detect double tap in unity how to make a variable unity how to get text color alpha unity how to set maxspeed rigidbody unity unity 2d desplay lives left two different keys for one Unity save runtime list values unity unity change camera scale on collider enter 2d unity disappear after time unity damage unity c in unity unity call function every x frames unity input system not working unity attach camera to gameobject how to clone something as a parent unity unity banner Ad position unity wait until bool is true damage unity now unity inheritance how to make a tutorial scene appear once in unity unity 2d platformer movement script rigidbody howto add unity webgl build to wordpress cannot convert from string to string[] unity render world space UI infront of everything unity latest unity version change sprite color unity change android sdk version unity how to declare an button in unity The namespace already contains a definition for unity unity latest version unity player move script unity dictionary get value how to add all items with a tag to a list in unity unity button onclick function not showing unity fps test map download unity suomeksi ios gps unity OpenVDB unity code command line options blank space code how to indent the whole block of code in cscode? light grey color code heart code for windows 10 visual code intellisense slow keyboard response how to remove text in vs code black color hex code matlab code for read table code typer code blocks md word wrap in visual studio code visual code remove line which contains autoformating for code in vscode when i save it visual studio code auto indent raspberry hex code how to code what is the code for red color how to delete visual studios code extensions VS Code Live Server configuration what is code review vs code run ng serve visual studio code download count line of code 409 status code bresenham line drawing algorithm code git push functions code swift_transportexception expected response code 220 but got an empty response vsix visual studio code move lines of code in vscode owlcarousel code unauthorized status code vs code a project folder from the command line vs code download lambda update-code ascii code special characters ascii code visual studio code keyboard shortcut delete line how to check code page from file postal code kasur what does the following code fragment print int n=50 vs code from console code grepper copy code highlight in readme code grepper on phone elementor dashboard remove code age code compile c code to llvm bootstrap navs tabs code d flip flop vhdl test bench code code to make an ai unable to start debugging visual studio code greater than equal to code telegram bot code node code execute jupyter notebook on .py file vs code visual studio code toggle vim 200 error code error: request failed with status code 400 change vs code title bar theme color how to run a scrip in vs code vs code select down visual studio code terminal window shortcut back select multiple lines in vs code ROYAL BLUE colour code vs code Modified alt code for arrow pointing right upload image in codeigniter 3 source code hex color code finder QR code in QT code pen status code 302 vs code

Browse Other Code Languages

CodeProZone