Connecting objects (eg. destroying a fuse box to open a door)


Some art

For this feature I made some textures and a model for a fusebox (both an intact and a destroyed version):



Connecting objects

As for the scanner, opening doors or basically almost any interaction the affected classes / scripts have an "interact" method with one object parameter that can be anything.

Since Godot loves duct-typing (https://en.wikipedia.org/wiki/Duck_typing) I can just check if the object has an interact method - or in some very specific cases I can check type but I think I'll convert those parts to method checks as well.

If interaction can be made, then, in the case of the fusebox and crossbow, the body of the fusebox is the object that interacts with the ray we cast as it was the crossbow projectile.

Since the main script for the fusebox is attached to the fuse box scene itself, we use the static body only as a proxy to call the actual interaction method.

Interactions like these are easy and the same can be said for connecting the objects. The fusebox - or any object that connects another one - only needs the node path for the door to get the door object...which has an interact method as well.

Ammo types and states for destroyable objects

I implemented ammo types as enum - later there will be a difference in the shooting animation as well:

  1. default
  2. shock
  3. explosive
  4. freezing
  5. any

The "any" AmmoType is basically an indicator for objects like the fusebox that any type of ammo can destroy them. Later this will be changed for the fusebox although to a specific ammo type.

When the crossbow interacts with the fuse box, we pass an object that contains informations including the ammo type, so the shot object can check it and react accordingly.

For destroyable objects like the fuse box, another enum was made with these values:

  1. intact
  2. destroyed

We can't do anything with a destroyed fuse box, but we can destroy an intact one, and if it happens, the fuse box will call the interact method of the door, thus opening it.

Possibilites

There can be a lot of interesting gameplay mechanics made with this features. We can for example shoot an object on the ceiling, thus making it fall on the enemies, or we can make puzzles with switches that connects to each other.

Get ShadowStalker

Leave a comment

Log in with itch.io to leave a comment.