Animate & Code a 2D Projectile in Unity 2018

Christopher Navarre, Software Instructor

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
2 Lessons (26m)
    • 1. Setup for Fireball Spritesheet Animation Unity 2018 Tutorial

      7:14
    • 2. Creating a Fireball Projectile with Movement, Collision, and Sound Unity 2018 Tutorial

      18:27

Project Description

Scripts and Sample Scene for this Series at: https://gumroad.com/l/FIREBALL

In order to make a projectile that will be able to interact with players and move around, you will have to create a game object for the projectile and the player. I recommend creating prefabs for both and later you can duplicate those with the gameObject.Instantiate method whenever you need to create them in your scene.

These game objects should be setup as follows

  • Character
    • BoxCollider2D
    • RigidBody2D (Kinematic Mode)
    • SpriteRenderer 
    • Character Script
  • Projectile
    • BoxCollider2D (Set to Trigger)
    • SpriteRenderer
    • Projectile Script

Challenges

  • If you want to improve on the scripts in the scene, try changing character into an interface or a base class that other scripts like a Player would inherit from.
  • Another good idea would be to allow the projectile to take a public Vector3 direction in the inspector and then to pass that into the transform.Translate call. Try to make it move in the direction the user sets up in the scene rather than always going to the right.

Student Projects