ShadowfallStudios / ALS-Community

Replicated and optimized community version of Advanced Locomotion System V4 for Unreal Engine 5.4 with additional features & bug fixes
Other
2.2k stars 581 forks source link

AI Yaw Rotation inconsistencies when focusing while aiming #212

Closed MilosLukic closed 3 years ago

MilosLukic commented 3 years ago

Describe the bug Hi, there is some inconsistency when AI controller is aiming and is focusing on the player. Sometimes it follows him with the weapon, and sometimes it follows him just with the head. It seems that the behavior is determined randomly and does not change after time. For example in the video below I used the test scene and left only archers in it. One archer was acting as expected - it was following the player with the weapon, and the other one was following him just with his head. I started the project multiple times, and next time the second one was acting as expected and the first one didn't - it seems quite random.

The pawn rotation (eyes rotation) is perfectly fine, you can also see in the video that the head is oriented in the right way. The issue is only when the pawn is not moving, if it's moving, it rotates the yaw as it should. The pitch rotation is also working as expected in all cases.

To Reproduce Steps to reproduce the behavior:

  1. Create a blank project
  2. Install the plugin
  3. Open the test level and delete everyone except bowmans
  4. Run around, if everything works as expected (for me it didnt, but since its random, it might), run it again

Expected behavior I'd expect that when aiming the weapon would always follow the target, not just sometimes.

Screenshots and Videos https://drive.google.com/file/d/1-JNtF6xQTal8nlsk0-WNl9zYi45VqWBH/view?usp=sharing

I know that working on community projects and fixing random bugs is not a pleasant thing to do, so I'm ready to help with fixing the issue, if you don't have the time (In that case I'd be happy to get some guidance where to look for the bug).

dyanikoglu commented 3 years ago

Looks like they're receiving target actor location without including capsule size. I believe it's caused by missing override for getting actors's eye position/rotation in our character class

dyanikoglu commented 3 years ago

Fixed with 15e4ebb, will be included in next release @MilosLukic

MilosLukic commented 3 years ago

Hey @dyanikoglu, unfortunately I am still getting that issue, I installed the 4.20 version on a fresh blank project. I don't think that the focus function was the issue, because eye rotation is correct with all the AI actors. The problem is in hands rotation, which is sometimes (randomly) not aligned with eye rotation. What I noticed so far:

  1. The rotation works fine while moving - problem is only when standing still and only in cca 50% of cases
  2. Sometimes it snaps to normal behavior and the hands follow the eye rotation correctly (lower link after 20s)
  3. Eye and body rotation is always correct, just the hands do not follow eye rotation when in aiming overlay
  4. It works in the blueprint vanilla version

Video using 4.20 https://drive.google.com/file/d/1-DWESa_CY8mj1AGM57BK1NGIKUJnqbrW/view?usp=sharing

Naineten commented 3 years ago

If you have same problem - https://github.com/dyanikoglu/ALS-Community/issues/135 . You can do this. It may be rough, but it works for me. image

MilosLukic commented 3 years ago

@Naineten it works! I tested it and the AI has correct rotation now. Thank you.

So we basically disable the spine rotation by setting the alpha to 1.0 if the rotation mode is "Aiming". Could this have any unwanted side effects? I'm not very familiar with enable_spinerotation functionality

Naineten commented 3 years ago

Why you think that 1.0 is disable of the spine rotation? 1 == True, 0 == False. Our problem is that sometimes animation have Curve_EnableSpineRotation == 0 when is must be ==1. And i don't know why this problem happens. I just set it by 1 manually on aim (rotation mode). Spine rotation is default in any other cases.

image

MilosLukic commented 3 years ago

My bad, I'm not very familiar with the layering, thanks for the clarification. The part that bothered me the most was the randomness - it was not rotating properly in cca 30% cases i think.