For testing purposes try and compare my method too, to have some rough numbers… You can see the events on my second reply or download the example from here…
https://drive.google.com/file/d/1Sf7qAwY_w74u1NGl9Z93FLgHfWbcXPtz/view?usp=sharing
For testing purposes try and compare my method too, to have some rough numbers… You can see the events on my second reply or download the example from here…
https://drive.google.com/file/d/1Sf7qAwY_w74u1NGl9Z93FLgHfWbcXPtz/view?usp=sharing
I might need more context, as I’ve tested the above numerous times both going from top left to bottom right, bottom left to top right, and the inverse.
Can you show what you’re testing with?
It may have something to do with your other selection events/how you’re selecting it, also you’ve changed some of the items around from how I have it.
You’re welcome to test my method here, I really quickly re-made it and exported to web:
https://games.gdevelop-app.com/game-ce887dc5-5f59-4615-898b-8b31ababb9b7/index.html
Here’s the events as it is currently, I added a key to reset the selection (r key on keyboard). I also removed the For Each per your mention.
The differences could be anything from event order, to layer info missing from some of your MouseX()/MouseY(), or because you’re trying to test for “in collision (inverted)”, which never seems to work as I’d expect it to without a for each object event.
im sure, its not my events that dont work.
the is not in collusion works fine.
none of this matters.
even without the deselect (not in collusion), same issue, filling layer/cam info, same issue.
i assume your initial size of the panel is very large?
i changed my events to exactly match yours, but the issue persists.
Yes, the one from the asset store is 128x128, but I’m not seeing this locally either. Are you on b105 or newer? I know they fixed some hitbox issues with b106.
Here’s an export with the tiny test image selector.
https://games.gdevelop-app.com/game-3793a0c5-8790-4231-9827-967664164aa7/index.html
(No reset key on this one)
Edit: Here’s an export with a 0x0 pixel default size selector, just to double check. Reset key is R
https://games.gdevelop-app.com/game-e4048a60-74c6-4b34-8a83-fe224f8b9b1e/index.html
yes, still on 105. might be the reason.
your link works for me.
But doesnt really matter, since collusion check is not the best way anyway.
Compare position is the most performant. and performace is badly needed in RTS games.
Absolutely. I just wanted to identify why it was working for me and not you.
Your method makes sense to me as well, just a bit more complex for a user to set up. Could be a worthwhile extension.
Yes, agree.
I tried to integrate a select function, but it didn’t work out that well.
For my rts example I stick to events only for now
I wonder if the best “extension version” of your method is just events to draw of the box, and conditions that test if an object is within the box. That way the user can do whatever they want with it selection wise/condition wise/etc.
I might poke at it this weekend if you don’t want to take a crack at it.
i´ll make an extension for it to just set the Object Variable Selected to 1 if inside and 0 if outside. the rest is up to the user.
Your version works.
But since its using collision aswell, I’ll stick to my method for the extension.
Real quick test with your idea, this seems to work. I’d make the first to subevents to be the actions, and the rest be the “Selection” behavior or something similar.
Feel free to optimize as needed or ignore.
free to test it.
Description:
Draw a Box with a Shape Painter Object.
Place a shape Painter object inside the scenes you want to Draw.
“Draw the Shapes relative to the object position on the scene” needs to be unchecked.
“Clear the rendered image between each frame” needs to be checked.
Selectable Objects should have ther Origin point at the Center.
On left click release, if a Box was drawn:
For Objects that are more then half inside the drawn Box, the Variable “Selected” of Object is set to 1
For Objects that are NOT more then half inside the box, the Variable “Selected” of Objects is set to 0
A left Click without drawing the box, will unselect all objects, exept the Object under the Cursor, unless the Ctrl key is pressed.
Multi-Selection by holding the Ctrl key.
Reserved Variables :
Scene Variables: “StartX” / “StartY” / “EndX” / “EndY” / “drawing”
Object Variable: “Selected”
remarks:
When the Boolean Variables are released to Version 106 of Gdevelop the Object Variable “selected” should be changed to Boolean.
Edit:
Box Selector with Boolean added.
this was indeed the issue, confirmed.
Wow thanks everyone. More information than I ever thought I’d get. I appreciate all the help.