-
Notifications
You must be signed in to change notification settings - Fork 27
[Rectangle Movement] Minor updates to add labels to controls #503
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
Conversation
Preview the game(s) changed or added in this Pull RequestThis is an automatic message displaying links to the games in this PR - double check the JSON in case of doubt. |
|
Images automagically compressed by Calibre's image-actions ✨ Compression reduced images by 54.5%, saving 5.05 KB.
4755 images did not require optimisation. |
I haven't thought about this. The advantage is that it allows to reverse the movement when a tween shape has started without strange speed change, but It's probably not very common.
I think it should work exactly the same with objects or groups. I think this aspect may confuse users. At least when they use the expressions themselves, they can know by experience that they need a for each and a way to find the right instance with a collision check for instance. There is still the issue of rectangles that might overlap 2 moving objects. Maybe the one that has the nearest edge should win? |
… RectangleMovement) This is what was breaking the object groups. :)
….com/GDevelopApp/GDevelop-examples into retangle-movement-move-around-object
… object But... it doesn't work.
I don't think we need to change anything, it just surprised me. I do understand what you mean about the toggle direction action; it could make the object teleport if it was using an asymmetrical easing.
I fixed this by making the original ship (and all related expressions) use the new behavior name.
I created a matching standalone function, but it doesn't seem to work. Can you review it?
Are you talking about how the creator will match each moving object with the correct center object? Great question! My first guess is that they could do a collision check (and perhaps create an object link at the start of the scene, instead of constant collision checks.) Do you think we should help them with this? (I think we should. Here is my plan:)
|
- LinkNearestObjects - Added ForEach and object linking to Move Along function.... which still does not work right :(
|
@D8H I tried making a stand-alone function but it is not working (the movement shape doesn't get changed to match the blue object). Can you look at it when you have time? |
The center is not the best criteria as moving objects are put on the border. The distance between the border and the moving object should give better results. This should also allow to set the right starting position. |
|
How do we find the distance to the border? The border is not a single position. Also, if patrol patterns (center object) overlap, it's hard to know which moving object goes with each one, unless the user places the moving object over the center point (similar to how joint connector works). |
By doing a projection. A rectangle is convex so there will only be one result. The problem can be split in 2 steps:
Points that are outside can be projected on the rectangle by doing a Every points are now inside the rectangle so no need to check either. Points that are inside must be projected on the nearest edges. The nearest edge distance is the minimum of the 2 delta of X and the 2 delta of Y. Each of the 4 delta can be checked to be the minimum and the points goes to that edge. |
- Object linking now loops into both object lists to cover situations where objects overlap. - Removed original "move object around another object" function
|
@D8H I think I found an elegant solution that is both easy to use and powerful. There is a single action that links each moving object to a center object, but only when the center point of the moving objects is inside the center object. This enables multiple moving objects to be placed on the center object, and assigned to a specific starting corner (thanks to your great design!) Screenshot of the event sheetVideoGDevelop_octe4IdSZG.mp4 |
What if one rectangle is inside another rectangle? (I think this is why distance from the rectangle edges is needed) |
|
@D8H I did it! Can this implementation be optimized? GDevelop_iRg5lj138U.mp4 |
|
From a quick glance:
|
|
I got this working as you described.
I have created 3 new private expressions functions for this. It does really simplify the extension, and those functions could be copied (manually) if other people want to use them. My only question is what names should I give the parameters? Currently, I'm using "CenterObject" and "MovingObject", but the functions are called "DistanceToClosestEdge" so the name doesn't fit well. Any ideas for these names? |
|
(Note: I'm repeating this question so it doesn't get missed) My only question is what names should I give the parameters? Currently, I'm using |
For private functions, keeping the same object name as the caller can be a good option. It's easier to copy paste events from one function to another and if the object name is not too much confusing, it lets code maintainers know it's the same object. |
|
Ok, that makes sense. Did you want any other changes on this PR before approving it? |
|
In the "Update rectangular movement to follow the border of object" group, the foreach on MovingObject is not necessary because the right MovingObject is picked by the LinkedObject action. The extra loop result to the work same work being repeated for each each MovingObject. The calculus doesn't handle some cases correctly (it chooses the big rectangle in the following screenshot). Please take a look at this previous message: #503 (comment) |
- Added temp testing scene for new functions
|
Images automagically compressed by Calibre's image-actions ✨ Compression reduced images by 11.4%, saving 46 bytes.
4994 images did not require optimisation. |
Nice catch, I agree that the linked condition selects the correct Moving object so no loop is necessary. I have removed the loop.
Ah, I do see the problem. In your example, the Y value is VERY close to the top edge of the object on the right. @D8H Thanks for taking the time to work on this! |
|
Current status:
|
|
What do you think about creating a dedicated example to explain the new action?
It could be something like: "Circular saw platformer" (or a better name). It could be a tiny level with saws on a moving platform. I think it could be useful to use the "teleport in a corner" action when the objects are linked to put the moving object at the nearest corner. |
|
That is a good idea. Do you prefer a new scene on this example, or a new example? |
|
I think a new example will be better because I can see people searching for this in particular. |
|
I wonder if there was anything I should change in this PR (or just close it) I know I added a change direction button, but I don't see a commit just for that change. |
It was already here. I think you added labels under the buttons, but I don't think it's necessary. |
The new 3D features also have created a lot of new things...
|
@D8H I have cleaned up this PR so that it only includes these changes:
I'll start the new PR for something like the saws that move around objects. |




Add an action to move along the rectangular border of an object.
Notes:
I tried using an object group to apply actions, but they didn't seem to work. I couldn't figure out what was happening so I just repeated the actions once per object.(fixed by renaming behaviors)