Ranged Enemy Aiming Problem | Tech Discussion
In this Tech Discussion I will be explaining how I solved a problem with our ranged enemies’ aiming logic.
Before the fix, when our ranged enemies fired a spell they would do the following:
- Begin playing a casting animation
- At the proper frame of the animation, spawn a projectile at the position of the enemies hand
- Calculate an angle from the projectile to the player, and launch it in that direction
The problem with this setup was that once the spell spawned it automatically aimed at the player, regardless of where the enemy was pointed, resulting in wonky situations like this where the enemy character placed their hand in front of them but the spell fired off to the side:
Additionally, this setup rendered useless the warning the player got from the enemy’s animation because by the time the spell spawned, it aimed right at the player even after they tried to dodge.
Here is the solution I came up with:
After spawning the projectile, cast a ray forward from the enemy:
If the ray has no hits, fire the projectile at the end of the ray:
If the ray does hit, aim at that first point:
Now if the player sees the enemy start their cast animation, they will be able to move out of the way and dodge the attack:
Author: Reilly da Silva
Get Mythicism
Mythicism
Status | In development |
Author | Arcane Studios |
Genre | Action |
Tags | 3D, Action-Adventure, Dungeon Crawler, Fantasy, Singleplayer, Third Person |
More posts
- DOT Particle Effect Not Working In Release Build | Tech DiscussionJun 24, 2022
- Tech Discussion | Boss Post MortemJun 23, 2022
- A Problem With Blade Trails | Tech DiscussionJun 10, 2022
- Tech Discussion | Boss BehaviorJun 10, 2022
- How To Edit Animation Sequences (Additive Layer Tracks) In UE4 | Tech DiscussionJun 03, 2022
- Tech Discussion | Altar System and Player levelingMay 23, 2022
- Tech Discussion | Save SystemMay 23, 2022
- Adding Varied Footstep Sounds | Tech DiscussionMay 15, 2022
- Designing A Souls-like Block Mechanic In UE4 | Tech DiscussionMay 14, 2022
Leave a comment
Log in with itch.io to leave a comment.