GDevelopApp / GDevelop-extensions

Repository of behaviors, actions, conditions and expressions to be used in GDevelop for creating games
https://gdevelop.io
MIT License
129 stars 51 forks source link

Average Values of Multiple Objects (Was: "FindCenterOfObjects: Find the center of a group of objects") #189

Closed tristanbob closed 2 years ago

tristanbob commented 3 years ago

Describe the extension

Provide X and Y position values for the center of a group of objects.

Checklist

Play here

https://games.gdevelop-app.com/game-23fde65c-7992-4ba6-9219-d90b670867bf/index.html

Extension file

FindCenterOfObjectsExtension_0.1.5.json.zip

Project files

FindCenterOfObjects.zip

Video

https://user-images.githubusercontent.com/8879811/126047490-c6a19718-574f-4c17-8a6d-bd5b0aac7129.mp4

Midhil457 commented 3 years ago

Hi, I really liked the extension. After playing with it for some time, I have some suggestions

:)

tristanbob commented 3 years ago
  • Providing conditions might be helpful

I'm not sure conditions make sense for an expression, but I might be wrong. What would the conditions be? Do other "expression-only" extensions provide conditions?

  • Is it possible to make it calculate with different objects and not only just the same object?

Yes, you would just use an object group instead of a single object.

  • The description is a bit short on info

This is a very simple expression (but one that is useful for a lot of reasons.) What do you think would be useful for users? I guess I could explain some use-cases (like flocking behaviors, camera tracking, etc)

4ian commented 3 years ago

As it's a very simple extension I think it's better to keep just the expression. In the future, we'll add a capability so that extensions can declare an expression and automatically get a condition made from it :)

Midhil457 commented 3 years ago

Makes sense

This is a very simple expression (but one that is useful for a lot of reasons.) What do you think would be useful for users? I guess I could explain some use-cases (like flocking behaviors, camera tracking, etc)

Yes, I didn't realize that it can be used for camera tracking until now, so the use case would be useful

:)

4ian commented 3 years ago

This icon looks a bit more suitable yes 👍

tristanbob commented 3 years ago

Please hold on adding this; I'd like to add some more "related" expressions.

Existing:

New:

Do you have any ideas on other expressions to include?

Midhil457 commented 3 years ago

TopX,TopY, BottomX and Bottom Y?

tristanbob commented 3 years ago

TopX,TopY, BottomX and Bottom Y?

What is the goal with this? To return the x,y of the top object (and the bottom object)?

I think I am going to add more functions that will help with RTS flocking and unit movement.

Reference:

Separation: steer to avoid crowding local flockmates Alignment: steer towards the average heading of local flockmates Cohesion: steer to move toward the average position of local flockmates

https://gamedevelopment.tutsplus.com/tutorials/3-simple-rules-of-flocking-behaviors-alignment-cohesion-and-separation--gamedev-3444

tristanbob commented 3 years ago

Adding more to todo list:

NeighborCount "PrimaryObject" NeighborObject"

Bouh commented 3 years ago

Is there a specific bottleneck or expectation that would help in the implementation of this extension? Part of this was added in your RTS game?

If there is no news within 3 days I'll close the topic and tag the extension as abandoned this Monday.

tristanbob commented 3 years ago

Eeek, please don't abandon this quite yet. :) I will have a lot more time to work on game dev in about 3 weeks. I'm currently much more busy than normal due to an event-based commitment.

When I get time, I will focus on finishing this extension (and perhaps others) before doing fun new stuff. Thanks Bouh!

tristanbob commented 2 years ago

I think I'm done for now. :) Let's get the review process started. Thanks for bearing with me!

Version 1.0.0

Provides average values of a group of objects. Useful for camera tracking, AI flocking behaviors, and more.

Included expressions:

Center position (mean)

Center position (medium)

Based on center of object:

Based on AABB of object:

Extension file

AverageValuesOfObjects_Extension_1.0.0.json.zip

Playable game

https://games.gdevelop-app.com/game-c418ef6d-93bc-4564-92b0-826625751ec1/index.html

Project files

AverageValuesOfObjects.zip

Video

https://twitter.com/VictrisGames/status/1447418614600982530

github-actions[bot] commented 2 years ago

Hi @tristanbob ! 👋 This submission has been moved to a PR as part of our submission pipeline. Please continue the submission process on this page. Thanks!