-
Notifications
You must be signed in to change notification settings - Fork 1
Appendices & bibliography
Nils Meijer edited this page Mar 21, 2024
·
5 revisions
A way to design AI behaviour, using a tree-like structure. The tree is built from a set of different node types. There is one “root node”, from which all other nodes are run. In my implementation, 2 different composite node types are being used.
[2] Unity, “Wheel Collider component reference,” Unity, 23 06 2023. [Online]. Available: https://docs.unity3d.com/Manual/class-WheelCollider.html. [Accessed 29 06 2023].
[3] Trijicon, “Advanced Mil-Dot: Estimating Distance Using Your Scope,” 28 08 2019. [Online]. Available: https://www.trijicon.com/community/post/how-to-use-trijicon-accupoint-mil-dot-riflescopes#:~:text=A%20MIL %2DDot%20reticle%20refers,to%20allow%20for%20range%20estimation
[4] C. Simpson, “Behavior trees for AI: How they work,” 18 07 2014. [Online]. Available: https://www.gamedeveloper.com/programming/behavior-trees-for-ai-how-they-work. [Accessed 05 2023].
[5] S. Castro, “Introduction to behavior trees,” 17 08 2021. [Online]. Available: https://robohub.org/introduction-to- behavior-trees/. [Accessed 05 2023].
[6] M. Pêcheux, “How to create a simple behaviour tree in Unity/C#,” 2 11 2021. [Online]. Available: https://medium.com/geekculture/how-to-create-a-simple-behaviour-tree-in-unity-c-3964c84c060e. [Accessed 05 2023]
- Sequence node: all child nodes have to return SUCCESS. Otherwise, if any child returns FAILURE, the node fails and stops checking the child nodes, and returns FAILURE itself.
- Selector node: if any child node returns SUCCESS, the node stops looping through the children and returns SUCCESS itself.
private void UpdateShellsVelocity()
{
foreach (Shell currentShell in _firedShells)
{
double deceleration = GetDeceleration(currentShell.RB) * Time.deltaTime;
currentShell.RB.velocity -= currentShell.RB.velocity.normalized * (float)deceleration;
}
}
private const float AIR_DENSITY = 1.2f;
private const float SHELL_FRONTAL_AREA = 0.035f;
private const float DRAG_COEFFICIENT = 0.1f;
private static double CalculateDragForce(Rigidbody rb) => DRAG_COEFFICIENT * 0.5f * AIR_DENSITY * Mathf.Pow(rb.velocity.magnitude, 2) * SHELL_FRONTAL_AREA;
private double GetDeceleration(Rigidbody rb)
{
double dragForce = CalculateDragForce(rb);
Vector3 currentVelocity = rb.velocity;
Vector3 inverseVelocity = currentVelocity.normalized * -1 * (float)dragForce;
double deceleration = currentVelocity.magnitude - inverseVelocity.magnitude;
deceleration /= rb.mass;
return deceleration;
}
My implementation of the drag coefficient formula. For every shell that has been fired and is still active, the drag force is calculated and applied to the current velocity. A mechanical engineering student/friend explained the formula as I am not very skilled in physics/math so I asked him for help, after which I did my own research and attempt at implementing it. Eventually, he helped me a bit with the implementation.
[1] The Engineering ToolBox, “Drag Coefficient,” [Online]. Available: https://www.engineeringtoolbox.com/drag- coefficient-d_627.html.[2] Unity, “Wheel Collider component reference,” Unity, 23 06 2023. [Online]. Available: https://docs.unity3d.com/Manual/class-WheelCollider.html. [Accessed 29 06 2023].
[3] Trijicon, “Advanced Mil-Dot: Estimating Distance Using Your Scope,” 28 08 2019. [Online]. Available: https://www.trijicon.com/community/post/how-to-use-trijicon-accupoint-mil-dot-riflescopes#:~:text=A%20MIL %2DDot%20reticle%20refers,to%20allow%20for%20range%20estimation
[4] C. Simpson, “Behavior trees for AI: How they work,” 18 07 2014. [Online]. Available: https://www.gamedeveloper.com/programming/behavior-trees-for-ai-how-they-work. [Accessed 05 2023].
[5] S. Castro, “Introduction to behavior trees,” 17 08 2021. [Online]. Available: https://robohub.org/introduction-to- behavior-trees/. [Accessed 05 2023].
[6] M. Pêcheux, “How to create a simple behaviour tree in Unity/C#,” 2 11 2021. [Online]. Available: https://medium.com/geekculture/how-to-create-a-simple-behaviour-tree-in-unity-c-3964c84c060e. [Accessed 05 2023]