How to code directional blocking ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AltoWaltz

Hello,

I have a character and character has a shield. When character is attacked and if player is pressing down b button the shield effect gets triggered.

This gets triggered no matter in which direction the shield is facing, even if away from the enemy. I would like to limit this to maybe just 90 degrees left and 90 degrees right. I suspect this is some trigonometry solution. Tried a lot with move direction, degrees, gradiants, etc.

Any idea ? Simple solutions also welcome.

Cheers.

The dot product is what you want to use I think! Take a look at the docs, there’s a good explanation. If you still need help, don’t hesitate! Vector math — Godot Engine (stable) documentation in English

MrEliptik | 2021-07-02 09:57

:bust_in_silhouette: Reply From: Kolandrious

Activate/deactivate predefined in editor collision shapes when pressing “block”