Module 4 Challenge

Tutorial

·

intermediate

·

+0XP

·

15 mins

·

(36)

Unity Technologies

Module 4 Challenge

This module focuses on creating and managing projectiles in Unity. Learners will build a projectile prefab, implement firing mechanics, and configure interactions such as collisions and explosions. The module also introduces using tags and particle systems for dynamic effects.

By the end of this module, learners will be able to:

  • Create and configure a projectile prefab with essential components.
  • Implement mechanics for firing projectiles.
  • Set up interactions for projectiles, including collisions and expiration.
  • Use particle systems to create explosion effects.
  • Utilize tags to identify and interact with specific objects.

1. Challenge

Challenge

Estimated Time: 15 minutes

In this challenge, experiment with the Rigidbody component and Force properties.

Challenge Steps

  1. Experiment with the ExplosiveShot prefab’s Rigidbody component; how does changing the mass, drag, and angular drag values affect the feel of the shot?
  2. Experiment with the cannon’s projectile force property. How does it affect the projectile’s firing properties relative to the gravity and drag properties of the projectile’s Rigidbody?

2. Bonus Challenge

Bonus Challenge

  1. The project does not account for the fact that a cannon barrel is smooth, which causes cannonballs to have a random spin when fired. Add the following line of code to the cannon’s fire method before applying force to the projectile:
rb.AddTorque(Random.insideUnitSphere.normalized * projectileForce, ForceMode.Impulse);

Add a new public float variable to the class called projectileTorque and update the AddTorque to use it.

Complete this tutorial