Hi,
Okay, so I'm very close to having a playable demo of my spaceship game, and I'm going into final tweaks and additions. One of the things that I left until last, because I thought it would be simple, was adding a shield/force field around my player spaceship which is activated at the press of a key.
Not so simple right!?
I've found plenty of tutorials about creating the visual aspects of the shield, and have a pretty cool looking effect done in shader graph, but no tutorials about dealing with the actual collisions, and sorting Tags.
Some details:
My enemies come in waves of 6, and each one has an 'Enemy' Tag. They have stats Health (10) and Damage (2), so when an enemy collides with the spaceship your health gets reduced by 2.
The spaceship has a rigid body, and a sphere collider and the collision event is set to detect the 'Enemy' Tag, obviously.
For my shield effect, I added a large Sphere as a child of the spaceship (0,0,0), added my shader graph material (looks good), and added a Sphere Collider to detect the collision of Enemies.
The problem is this:
Because the shield Sphere Collider is a child of the spaceship, when an enemy hits the shield it also activates the Health FSM and reduces the player's health by 2 (enemy damage). Not the most practical shield.
I've tried various things to get this right, but to be honest, I can't do it. I thought this would be an easy part!
I'm sure the solution lies somewhere in Tags and/or Layers, but when I start experimenting I end up losing the hit detection of the spaceship shooting (raycast - hit 'Enemy' Tag) and the collision event that sets damage done to the spaceship.
Maybe Compare Tags? Somehow?
I'm kind of going round in circles with this and would love some help.
All the best,
J.