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

Update BoidsMovement.json #1286

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions extensions/reviewed/BoidsMovement.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
"name": "BoidsMovement",
"previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Glyphster Pack/Master/SVG/Restaurant/Restaurant_restaurant_seafood_animal_fish.svg",
"shortDescription": "Simulates flocks movement.",
"version": "0.2.2",
"version": "0.2.3",
"description": [
"Simulates swarms or flocks movement following the separation, alignment, cohesion principles. The flock can be attracted to a location or avoid some obstacles.",
"",
"The [Fish School example](https://editor.gdevelop.io/?project=example://fish-school) shows how properties impact on the movement."
"The [Fish School example](https://editor.gdevelop.io/?project=example://fish-school) shows how properties impact on the movement.",
"",
"Update 0.2.3:",
"- fix activate/deactivate behavior not working."
],
"origin": {
"identifier": "BoidsMovement",
Expand Down Expand Up @@ -202,6 +205,9 @@
" this.behavior = behavior;",
" }",
"",
" isActivated() {",
" return this.behavior.activated;",
" }",
" /**",
" * Add a custom intent.",
" * @param {Boid} boid",
Expand Down Expand Up @@ -456,8 +462,12 @@
" * Move all instances.",
" */",
" moveAll() {",
" this.boids.forEach(boid => boid.flock());",
" this.boids.forEach(boid => {",
" if(!boid.isActivated()) return;",
" boid.flock();",
" });",
" this.boids.forEach(boid => {",
" if(!boid.isActivated()) return;",
" boid.move();",
" this.removeFromRBush(boid);",
" this.addToRBush(boid);",
Expand Down Expand Up @@ -709,7 +719,7 @@
"const object = objects[0];",
"const behaviorName = eventsFunctionContext.getBehaviorName(\"Behavior\");",
"const behavior = object.getBehavior(behaviorName);",
"runtimeScene.__boidsExtension.boidsManager.add(behavior);"
"behavior.activated = 1;"
],
"parameterObjects": "Object",
"useStrict": true,
Expand Down Expand Up @@ -743,7 +753,7 @@
"const object = objects[0];",
"const behaviorName = eventsFunctionContext.getBehaviorName(\"Behavior\");",
"const behavior = object.getBehavior(behaviorName);",
"runtimeScene.__boidsExtension.boidsManager.remove(behavior);"
"behavior.activated = 0;"
Comment on lines -746 to +756
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By removing this line, deactivated Boids will stays in the R-Tree and will continue to have side effect on other Boids.
A behavior already have a activated() accessor, but it's not needed. What should probably be done is to remove the Boids from boids.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the error, by removing the boid from the R-tree it forgets its original behavior when reactivated, so my solution is to pause and then resume it when needed

],
"parameterObjects": "Object",
"useStrict": true,
Expand Down Expand Up @@ -2199,4 +2209,4 @@
}
],
"eventsBasedObjects": []
}
}