-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Automate position updates (track game object position automatically) #6
Comments
Yes this could be very very useful a specially on performance side. |
Good news, I asked JCash and he says it is implemented: https://defold.com/ref/stable/dmGameObject/#GetPosition:instance Is this what is needed? |
Not sure. I guess this is only for GameObject which is created on C side. |
There is |
It is not documented but looks like it is what we are looking for. There is a test for it: |
@8bitskull are you still using this on Void Scrappers? If so and you got time, I'm going to test this. Since it is not a released function I can't promise for making it work. |
Yes I am, will gladly help in testing. |
@8bitskull Ok. Then please give me a few days. I got a project release this week. I'm going to try to figure this out as soon as possible. |
@8bitskull +also maybe I can prepare a much more custom version for the game. Which doesn't require checking collision on every frame(maybe just using callback). I can't promise, but I want to contribute on this if I had time. |
Thank you very much @selimanac. I have managed to create a pretty good system by batching updates, so I think a custom version of the extension is not quite necessary. The extension itself is already massively useful - if you manage to implement the two issues I have raised it will be even more so and I will be able to use it in lots of future projects I have in mind as well! ...Well, we'll see how the game performs when I try to port it to Switch. But I think it will be my code that is the bottleneck, not this extension. |
@8bitskull I figure that out and it is possible to get position from C now. But require a more work on extension side. I will had to keep all the go instances, get their positions and maybe trigger a callback. This is going to be quite big change on the internals. I hope I can manage it on the next week. I am planning to use callbacks because it will save a lots of performance. Not just for your project but every other projects... |
Good luck! Please don't rush on my account, the demo performs adequately and full release is many weeks away. Regardless, I look forward to seeing the result! |
@8bitskull Update: unfortunately I couldn't work on this last week. But I started today. My initial plan was the re-wrote the all thing but it seem like it's gonna take a long time. So I decided to go with a patch. We will have to do a lots of test :) |
@8bitskull Update: Almost ready for testing. Since I made a lots of critical changes I want to test it as much as I can. I'm going to build a simple game to see if everything works fine before send it to you. It is going to take a few more days I presume. |
Hi @8bitskull , I'll wait until you have been test this and when everything is fine then I'm going to release a build. It is here for now: There are two major functions related to Gameobjects:
local go_url = msg.url("/go")
local w = 50
local h = 50
local aabb_id = aabb.insert_gameobject(enemy_group, go_url, w, h)
This is the recomended way of removing Gameobject and its AABB. These are pretty straight forward but you can check out the example project which I just develop if you need to. Also updated the example on this repo: There is two new more functions:
There is more on release notes. I'm going to close this issue. Feel free to open new one... |
Excellent work @selimanac , thank you very much. Will let you know if I encounter any issues. |
I use go.animate() to move a lot of objects in a performant way. However I need to constantly update the aabb position for these objects, which means go.get_position() followed by aabb.update(). In my test, doing lots of updates was worse than the collision checking queries.
Britzl on Defold forums:
"The dmGameObject namespace has getPosition() but it requires a dmGameObject::HInstance. Not sure if there is a way to pass ids from Lua and turn them into dmGameObject::HInstance. If there is then you could provide the extension with a bunch of ids to keep updated and in the extension update function you could get the positions and update the aabb’s. @JCash will know if this is possible or not."
The text was updated successfully, but these errors were encountered: