Defold Timer - The native timer extension


#21

How would that help if you absolutely want it done in the same frame? The system we have in place is asynchronous as it is and I don’t see how the buffer size would have anything to do with it.


#22

This is unrelated.
As what i want can’t be achieved, i am forced to live with current implementation. And in that miserable life large buffer is a little helpful. It is 128 in 3D, why not give the same (or more) for 2D?


#23

Ah, I see. That’s DEF-2026. I’ll see what I can do about that one.


#24

BTW, why is this important? I’m not asking to be mean here, I’m asking because I’ve never used the ray cast functionality and haven’t really considered the use cases and potential problems of not having it immediate and synchronous.


#25

Chiming in since I have done a fair share of raycasting. The current implementation with message results works fine but it forces some bookkeeping that can get hairy if you’re not careful. Your idea of having a callback directly in the call within the current context should definitely help with that.

That you get no result on ray cast misses is worse, I think. It’s perfectly possible to keep a count on incoming rays and check the next frame for misses, but you loose a frame and again, the bookkeeping can become a bit hairy.


#26

I will try to explain…
Imagine simple platformer game with player and obstacles.
How we move player in that world?

Every frame we somehow calculate player_delta_position value that we add to player_position.
But because we have obstacles in our way, we should correct that value.

First, we fire bunch of horizontal rays and get corrected_player_delta_position_x value in return.
Second, we cast vertical rays. But what start_x for vertical rays should be?
It should be player_position_x + some_offset_x_for_concrete_ray + corrected_player_delta_position_x.

Here the issue. In Defold, we request all rays at once. But corrected_player_delta_position_x available only after raycast_response.
When we have moving platforms, pushable and stackable crates things get “hairy” and out of control very quickly.

I can’t say what that is impossible. Actually, i have working implementation with all of those things. It looks good at runtime. But this is definitely not should be implemented that way. I end up with sealed tilemaps, rays with 5-10k pixels length (that way ray always hit something) and crazy logic. And i reach raycast buffer length limit.

What I give up to implement, is slopes. If anyone has working implementation of how to climb and descend slopes in Defold (using raycasting), a would like to see the code.


#27

Hmm, ok, but why don’t you simply correct the player position as an aggregate of contact_point_response messages received for all collisions during the frame? What’s the added benefit of all of these ray casts in a platform game?

When it comes to slopes I believe @Mathias_Westerdahl has posted about his adventures with slopes in Defold.


#28

Because using ray casting for character motion a lot more predictable and easer to analyze and respond. Because this way we prevent a collision, rather than solve it. Because it is not always possible to decide in which direction solve collision.

With raycasting you control everything, with contact_point_response you control nothing. Almost every good platformer use raycasting for movement. This is a common practice.


#29

There seems to be a conflict between ‘googleanalytics’ and ‘timer’.
I want to use both libraries, but I can not use them.


#30

Really? How do you mean conflict? What kind of message are you getting? I had no problem adding both as dependencies and using them.


#31

If you first call ‘googleanalytics’ and call ‘timer’, the script will not find ‘googleanalytics’.
If you call ‘timer’ first and call ‘googleanalytics’, your script will show that there is no ‘timer’.

And if you delete ‘timer’, ‘googleanalytics’ crashes alone.


#32

I’m not sure I understand. Would you mind posting some code?


#33

There is no code used separately.

local ga = require "googleanalytics/ga"

and

local id = timer.seconds(1.5, function(self, id)
  print("I will be called once, unless I'm cancelled")
end)

I used this this way.

I repeatedly ran ‘fetch libraries’ on a library I could not find. I have repeated it many times and now it works. I do not know why.


#34

Ok, good to hear that you got it working!


#35

@dmitriy This issue has been resolved but it didn’t make it into the beta for 1.2.101. Let me know if you want to try it out sooner and you’ll be able to test it using the alpha.


#36

Thanks for that.
I can wait for release version.


#37

Ray cast buffer size has been made configurable in Defold 1.2.102


#38

Can not use the timer function on your phone?

I tried to build, but I get an error message ‘Build server output’.


#39

Are you building for iOS or Android? And from a Windows, Linux or Mac machine? I’ve tried building for Android from a Mac and that works. Do you get any additional information?


#40

I entered https://github.com/britzl/defold-timer/archive/master.zip in ‘dependencies’ in ‘game.project’. And ‘Fetch Libraries’.

I tried to building for Android on my Mac, but that does not work.

If an error occurs, ‘Resource’ points to ext.menifest.