Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turret behavior predictive aim bug #7965

Closed
TackerTacker opened this issue Apr 24, 2024 · 4 comments
Closed

Turret behavior predictive aim bug #7965

TackerTacker opened this issue Apr 24, 2024 · 4 comments
Assignees
Labels

Comments

@TackerTacker
Copy link

Problem description

The predictive aim in the Turret behavior seems to have a bug.

msedge_2024-04-24_12-32-17.mp4

In the video (or running the project) it looks like there are 3 phases

  • 1st one the predictive aiming works and hits every shot.
  • 2nd phase it aims behind the player.
  • 3rd phase it shoots in the air.

My guess for the 3rd phase is that there is no actual solution at the speed of the bullets and player, so the equation just results in weird angles. I wish it would fail more gracefully, maybe reverting back to just pointing straight at the player without predictive aiming, but the 2nd phase is actually what really feels like a bug to me. Feels like it's off by 180°

( As a side note, I wish the aim angle would be available without the need to actually turn the object itself. Similar to how the Sine behavior has a "Value only" output option [ But I know that's not a bug ] )

Attach a .c3p

turret_auto_aim_bug_01.zip

Steps to reproduce

  1. Just open the project and run it

Observed result

The Turret Behavior is not able to predict the shot reliably, even if the player is moving at a constant speed and the turret rotation speed is high enough to be instantaneous.

Expected result

The Turret Behavior should predict shots more reliable and maybe fail more gracefully in case a shot is impossible.

More details

Affected browsers/platforms:

First affected release:

System details

View details

PASTE HERE

@AshleyScirra AshleyScirra self-assigned this Apr 24, 2024
@AshleyScirra
Copy link
Member

Sorry, I don't know how to fix this. I didn't come up with the predictive aim maths myself, and I don't really know why it would produce weird results like that. It already reverts to basic aim if there is no solution and this project shows that happening, but it seems in extreme cases just before it gets to "no solution" it ends up with "wrong solution". If you can figure out the correct maths or checks to avoid this case perhaps it could be implemented, but otherwise I would say either use basic aim or design the project to avoid this happening.

@TackerTacker
Copy link
Author

Hmmm that's too bad, I appreciate you looking into it anyways.

@TackerTacker
Copy link
Author

I asked R0j0hound for help and he found a solution.
He created a working example using events. I think he figured out that there are 2 possible solutions to the problem and currently the Turret Behavior basically picks the wrong one, or maybe doesn't account for 2 solutions? Idk, I don't understand the math, R0j0hound would have to explain it.

Anyways, here is the example project
turret_behavior_aim_bug_and_event_based_solution2.zip

@TackerTacker
Copy link
Author

R0j0hound made another version in which he added a 2nd solution he thinks is closer to the original formula of the Turret behavior.
turret_behavior_aim_bug_and_event_based_solution3.zip

He says his 2nd version is very similar to the 3rd solution described in this article "Strategy # 3 - Assuming Zero Acceleration" https://www.gamedeveloper.com/programming/predictive-aim-mathematics-for-ai-targeting#close-modal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants