In this article, we will create the attack of the Spider. The Spider will fire a ranged acid ball in the direction of the Player when the Player comes within range.
The Acid Effect script is attached to the projectile fired by the Spider. It contains a few variables to control the movement and lifetime of the shot.
In Start, we set the GameObject to destroy itself after the delay.
In this article, we will set up the enemies to attack the Player. The enemies will attack the Player when attacked, and they will be able to damage the Player.
The enemies are set up similar to the Player in the previous article. They have a Hitbox that is activated by the Attack animation. In the Animator for the Skeleton, we transition to the Attack animation whenever the In Combat bool is true and then go back to Idle. The other change we make is that the Skeleton will only walk if In Combat is false.
In this article, we will add the IDamageable interface to the Player from the previous article. This will allow us to damage the Player with a Trigger-able Collider and play a death animation when out of health.
In the Animator for the Player, we make any state transition to the Death animation whenever the Dead trigger is activated.
This article will show how to use an interface to allow the Player to damage and destroy an Enemy. An interface is a script that requires that methods and properties outlined in the interface be implemented when inherited by a class.
To have the Enemy show that it has been attacked, we add a Trigger for Hit and set the hit animation to play from any state and then transition to idle.
This article will cover some of the main differences between an abstract class and an interface in C#. Abstract classes and interfaces are both used to create abstraction. Abstraction in C# is the process of defining the essential details to call operations (i.e., methods) without including the implementation details.
These are the main differences between an abstract class and an interface that you will run into when using them.
This article will show how to create a simple Hitbox for the Player’s attack. The Hitbox will be activated and deactivated in the attack animation. It will also use the physics layers, so it does not trigger from the Player.
The Hitbox has a Box Collider 2D and Rigidbody 2D components and is a child of the Sprite. As a child, it can be affected by the Animator. The Box Collider 2D is set to be a trigger and is disabled. In the attack animation, the Collider is enabled and disabled.
This article will show how to set up an Enemy base class that the other enemies will inherit. One advantage of using inheritance is that it prevents you from writing the same or similar code multiple times in different scripts. All three enemies are inheriting from the same script for their movement.
All three enemies are inheriting from the same script for their movement. We will go over the setup for the Moss Giant, but the other enemies are set up the same way.
We will make the Enemy base class abstract so that we can force the inheriting scripts…
This article will show how to set up a sword swing for a 2D character when the Player presses the left mouse button. We will also add an animation for a sword arc effect to make the sword swing more visible.
Animator Controller for the Player is set up to play the Attack animation when the Attack Trigger is set. Then goes back to playing the Idle or Run animation.
This article will show how to create and set up a 2D character in Unity. The 2D character will be able to move around the screen and jump.
The Player script needs a few variables to control the movement of the character.
This short article will show how to give the Tilemap colliders for the tiles and then use Composite Collider to combine all the individual tile colliders.
To give all of the tiles on Tilemap colliders, select the Tilemap and add the Tilemap Collider 2D component. Now all the tiles have a collider according to the Alpha of the sprite.