can you add like enemy Health bar? so they don't die instintly + when you kill them blood particles will shower you? if you could that will be great . just a note your videos are amazing!
I enjoyed this video a lot, you explained movement pretty well, I'm searching for how to make enemies avoid obstacles while also chasing the player, I'm pretty stuck on that. Do you have any suggestions?
Just doa check collision when the enemy touches the player you restart the scene: First at the top of the script do (using unityengine.scenemanagment) Then, write(Oncollisionenter(collision col): If(col.gameobject.tag == "enemy" Scenemanager.loadscene("You put her the index of the level")
is anyone having an issue where the enemy isn't destroying the player when it collides with it? (Fixed - make sure that the player has been tagged as a player)
I did every. single. bit of code you did, EXACTLY, replaying the video at least 10 times. My enemy still isn't moving. Please help me figure out what's going on.
@@MuddyWolf How about a boss where it has an HP and armor bar in which you have to get to zero before the boss starts taking health damage? Too much? >.
You can copy and use the code from the video for free, however if you don't want to copy it out then you can get it via my Patreon by subscribing as a "Beta Wolf" - this is to support the channel and the tutorials I make for free.
unfortunately there is something wrong with how i did it. it says "Assets\Enemy.cs(31,92): ; expected" Any help would be amazing. The my code is in the comment. I tried running it through spell check but I couldn't find anything. I also checked the tags and that not it ether. I tested it at 9:33 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Enemy : MonoBehavior { public Transform target; public float speed = 3f; public float rotateSpeed = 0.0025f; private Rigidbody2D rd; private void Start () { rb = GetComponent < Rigidbody>2D(); } private void Update () { if (!target) { GetTarget(); } else { RotateTowardsTarget(); } } private void FixedUpdate () { // move foward } private void RotateTowardsTarget () { Vector2 targetDirection = target.position - transform.position; float angle = Mathf.Atan2(targetDirection.y, targetDirection.x) * Mathf.Rad2Deg - 90f; //the - 90f is because the triangle is naturally facing up. This will make it face the player. Quaternion q = Quaternion.Euler(new Vector3(0, 0, angle)); transform.localRotation = Quaternion.Slerp(transform.localRotation, q, rotateSpeed) } private void GetTarget () { target = GameObject.FindGameObjectWithTag("Player").transform; } }
Access the FULL source code on my Patreon here: www.patreon.com/posts/2d-shooter-code-85313134
great video helped me a lot
can you add like enemy Health bar? so they don't die instintly + when you kill them blood particles will shower you? if you could that will be great .
just a note your videos are amazing!
appreciate the videos man!
Amazing video! helped me so much, Thanks!
Awesome! I'm happy it helped, Jetsi!
Thank you very much! On to the next one.
I enjoyed this video a lot, you explained movement pretty well, I'm searching for how to make enemies avoid obstacles while also chasing the player, I'm pretty stuck on that. Do you have any suggestions?
Ooo you can use A* pathfinding! If you RUclips it you'll find loads of tutorials but I recommend brackeys tutorial!
When the enemy touches my player, the player starts spinning forever.
Just doa check collision when the enemy touches the player you restart the scene:
First at the top of the script do (using unityengine.scenemanagment)
Then, write(Oncollisionenter(collision col):
If(col.gameobject.tag == "enemy"
Scenemanager.loadscene("You put her the index of the level")
Is there anyway to make the zombies take more shots to kill?
very good tutorial btw keep it up. would love more to this tutorial serie.
Very good video you are great
Thank you so much 😀
this helps a lot thanks
can you help I have a problem on the 'Vector' could not be found
is anyone having an issue where the enemy isn't destroying the player when it collides with it? (Fixed - make sure that the player has been tagged as a player)
how do you do that ?
I did every. single. bit of code you did, EXACTLY, replaying the video at least 10 times. My enemy still isn't moving. Please help me figure out what's going on.
Do you have a fix yet? I’m experiencing the same issue and I’m on a time restraint with this being a school project. Please share if you do have a fix
@@ByteKnite I don’t sadly. I just kinda abandoned my project
@@jankystreams3337 I just deleted and retyped the code and it just started working. Idk what I changed but it started working
@@ByteKnite That’s weird. Thanks.
Hello can you help me I have some problem about the enemy
Yay tysm!
You're welcome! :)
My player spawns on top of the enemy then cant move, someone pls help
Did you fix it.
How is the word "other" italicized?
make him die from many bullets, that is to say: that the enemy has invisible life for the player but that he dies from 2 or 3 shots
Nice idea! We could add a life count and each bullet will take one life away until they die!
@@MuddyWolf 👍
@@MuddyWolf How about a boss where it has an HP and armor bar in which you have to get to zero before the boss starts taking health damage? Too much? >.
9:21
plz give code for free
You can copy and use the code from the video for free, however if you don't want to copy it out then you can get it via my Patreon by subscribing as a "Beta Wolf" - this is to support the channel and the tutorials I make for free.
unfortunately there is something wrong with how i did it. it says "Assets\Enemy.cs(31,92): ; expected"
Any help would be amazing. The my code is in the comment.
I tried running it through spell check but I couldn't find anything. I also checked the tags and that not it ether.
I tested it at 9:33
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehavior {
public Transform target;
public float speed = 3f;
public float rotateSpeed = 0.0025f;
private Rigidbody2D rd;
private void Start () {
rb = GetComponent < Rigidbody>2D();
}
private void Update () {
if (!target) {
GetTarget();
} else {
RotateTowardsTarget();
}
}
private void FixedUpdate () {
// move foward
}
private void RotateTowardsTarget () {
Vector2 targetDirection = target.position - transform.position;
float angle = Mathf.Atan2(targetDirection.y, targetDirection.x) * Mathf.Rad2Deg - 90f; //the - 90f is because the triangle is naturally facing up. This will make it face the player.
Quaternion q = Quaternion.Euler(new Vector3(0, 0, angle));
transform.localRotation = Quaternion.Slerp(transform.localRotation, q, rotateSpeed)
}
private void GetTarget () {
target = GameObject.FindGameObjectWithTag("Player").transform;
}
}
as the error says, you're missing a ; on line 31 col 92,
transform.localRotation = Quaternion.Slerp(transform.localRotation, q, rotateSpeed);
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemigo : MonoBehaviour{
public Transform target;
public float speed = 3f;
public float rotateSpeed = 0.0025f;
private Rigidbody2D rb;
private void Start(){
rb = GetComponent();
}
private void Update()
{
if (!target)
{
GetTarget();
}
else
{
RotateTowardsTarget();
}
}
private void FixedUpdate() {
//Move Forwards
}
private void RotateTowardsTarget() {
Vector2 targetDirection = target.position - transform.position;
float angle = Mathf.Atan2(targetDirection.y, targetDirection.x) * Mathf.Rad2Deg - 90f;
Quaternion q = Quaternion.Euler(new Vector3(0, 0, angle));
transform.localRotation = Quaternion.Slerp(transform.localRotation, q, rotateSpeed);
}
private void GetTarget () {
target = GameObject.FindGameObjectWithTag("Player").transform;
}
}
Ahí tienes la versión sin errores xd habían cosas que fallaste que no falle pero yo falle en un } xddd, igual gracias por compartir me sirvió.