I need accurate timedelta()

The problem I have is the collision system that I need to be very accurate. So in addition to the masks I add a second condition of if distance is lower than “x” between the 2 colliding instances. This distance is multiplied by timedelta () in the same way as it is done when adding forces to the instances with the built-in system. The distance timedelta value and the forces timedelta value do not match because the collision checks return true one frame after the add forces frame. I have fixed this with a scene variable that saves the value of the previous last frame to check for collisions with that value, the variable is refreshed at the end of the code: previousTimeDelta = TimeDelta ()

Still I have problems and collisions skip sometimes. is there something i am doing wrong? How precisely works the condition “if the distance is less than “x” between two instances”? any advice?

TimeDelta() seems accurate, considering the number of decimals.

If the forces are too high compared to the objects’ size, collisions are skipped.
Game screenshot?

1 Like

I think the problem is related with if the collision and distance are true then I add permanent forces. The problem is that these forces are updated in the next frame before the collision event because they are forces built-in and I don’t have control of it. So the instance is moved 2 times before the next collision event.

Anyway I am going to make experiments to test in what moment of the frame is moved an instance with permanent force.

Is there any document with events order of actions built-in?

You can always adjust the Timedelt() just add multiply number like 1*Timedelta() or 0.6*Timedelta()

I don’t know what you mean, anyway I just want to know only one thing:

the permanent force built-in is increased before or after of the collision events?

because if the permanent force is after of collision event then the timedelta of force and collisions are of different frames, example:

frame event order with timedelta no match (bad) :

collision events: no collision detected with timedelta of frame 1
permanent forces built-in: movement with timedelta of frame 1
next frame:
collision events: collision detected with timedelta of frame 2

frame event order with timedelta match(ok):

permanent forces built-in: movement with timedelta of frame 1
collision events: collision detected with timedelta of frame 1

I need match timedeltas of collision and forces.
What order of these two is the order of gdevelop?

Events will occur in whatever order you have them in the event sheet from top to bottom.

If the collision check event is higher than the force, it’ll be checked first. If the force is higher than the collision, it’ll be checked first. All events are checked every frame that their conditions are met.

Note: if your force is so strong that it would oush the objects past the collision in one frame, collision may be ignored entirelt depending on event order.

1 Like

force is not in the code since is permanent, not instant. gdevelop makes it automatically in a certain moment of the frame, what moment is that?

Force is in the code as it occurs in whatever event you start the force in, otherwise it doesn’t exist. What you’re thinking about with permanent force is that it’s happening in the pre-step of events after it is started. Pre-step actions are only for basic behaviors or base engine code, and happens every frame before all events.

Permanent force is designed to never stop unless you use “stop the object” as an action. With this in mind, if the above statement still applies. If your force is too strong, and your object moves past the collision object in 1 frame, it will not fire off any related collision events.

None of this has to do with timedelta, however.

1 Like

This is the right answer, everything else not necessary. Thank you!

Btw is this information in any place? because it seems that one has to be born taught.

Well sometimes things get strange and I start to check everything and I did not know for sure when the movement occurred, I think it is important to know anyway. I imagine it has happened to you that you do not know where to look to understand what is happening.

No, not really. There’s a reason why permanent force is explicitly called out in numerous places on the wiki as something that should only be used if you don’t intend to interact with the object frequently or at all after activating the force.

When I use forces, I use instant forces with appropriate conditions so I can control where it is being activated and how it interacts with other objects.

1 Like

I am not having problems with the forces at the end but I needed to understand the internal behavior.

Great you can code all possible, perfect coder.

Maybe I’m not understanding what you’re asking, but you explicitly put the response in regards to forces. My response was stating that no, I use forces how the wiki describes to use forces.

If you’re looking for the mechanics, I’d strongly recommend reading through the wiki.

Thank you! I’m investigating