mirror of
https://github.com/4ian/GDevelop.git
synced 2026-10-12 02:01:17 +00:00
Fix pathfinding movement angle condition (#4825)
* Add a condition to check the movement angle of the top-down movement behavior.
This commit is contained in:
@@ -179,9 +179,8 @@ namespace gdjs {
|
||||
|
||||
movementAngleIsAround(degreeAngle: float, tolerance: float) {
|
||||
return (
|
||||
gdjs.evtTools.common.angleDifference(
|
||||
this._movementAngle,
|
||||
degreeAngle
|
||||
Math.abs(
|
||||
gdjs.evtTools.common.angleDifference(this._movementAngle, degreeAngle)
|
||||
) <= tolerance
|
||||
);
|
||||
}
|
||||
|
||||
@@ -358,7 +358,22 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Angle to compare to (in degrees)")))
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetAngle");
|
||||
|
||||
aut.AddScopedCondition(
|
||||
"IsMovementAngleAround",
|
||||
_("Angle of movement"),
|
||||
_("Compare the angle of the top-down movement of the object."),
|
||||
_("Angle of movement of _PARAM0_ is _PARAM2_ (tolerance"
|
||||
": _PARAM3_ degrees)"),
|
||||
_("Movement"),
|
||||
"CppPlatform/Extensions/topdownmovementicon24.png",
|
||||
"CppPlatform/Extensions/topdownmovementicon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "TopDownMovementBehavior")
|
||||
.AddParameter("expression", _("Angle (in degrees)"))
|
||||
.AddParameter("expression", _("Tolerance (in degrees)"));
|
||||
|
||||
aut.AddCondition("XVelocity",
|
||||
_("Speed on X axis"),
|
||||
|
||||
@@ -68,7 +68,10 @@ class TopDownMovementBehaviorJsExtension : public gd::PlatformExtension {
|
||||
.SetGetter("getAngleOffset");
|
||||
autConditions["TopDownMovementBehavior::AngleOffset"].SetFunctionName(
|
||||
"getAngleOffset");
|
||||
// Deprecated, prefer IsMovementAngleAround instead.
|
||||
autConditions["TopDownMovementBehavior::Angle"].SetFunctionName("getAngle");
|
||||
autConditions["TopDownMovementBehavior::TopDownMovementBehavior::IsMovementAngleAround"]
|
||||
.SetFunctionName("isMovementAngleAround");
|
||||
autConditions["TopDownMovementBehavior::XVelocity"].SetFunctionName(
|
||||
"getXVelocity");
|
||||
autConditions["TopDownMovementBehavior::YVelocity"].SetFunctionName(
|
||||
|
||||
@@ -217,6 +217,14 @@ namespace gdjs {
|
||||
return this._angle;
|
||||
}
|
||||
|
||||
isMovementAngleAround(degreeAngle: float, tolerance: float) {
|
||||
return (
|
||||
Math.abs(
|
||||
gdjs.evtTools.common.angleDifference(this._angle, degreeAngle)
|
||||
) <= tolerance
|
||||
);
|
||||
}
|
||||
|
||||
setMovementAngleOffset(movementAngleOffset: float): void {
|
||||
this._movementAngleOffset = movementAngleOffset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user