![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | nineGradens |
Suppose I have two objects, each with an animation, and I want to know when during their animations they are going to intersect… WITHOUT running said animations.
As a cludgy example:
while(ttt < 5)
$thingA.position = $Animator.get_animation("anim").track_get_key_value(0,track_find_key (0, ttt));
$thingB.position = $Animator.get_animation("anim").track_get_key_value(1,track_find_key (2, ttt));
print($thingA.overlaps_area ( $thingB))
Of course… this won’t WORK because “overlaps_area” only updates on each physics step.
So… is there any way to tell the engine “Please check if these two things overlap, right now, no, I don’t care about physics. Do they overlap?”
I don’t know much about Area2D
and the physics engine, but maybe you could set a Transform2D
for the two objects, and test whether they overlap. It looks like the engine does that for the test_move()
function. So you may be able to use it in your situation.
Ertain | 2019-07-14 23:25
Thank you Ertain,
This is EXACTLY what I needed.
I now feel a bit silly for not reading the relevant docs…
Not entirely sure how well this will apply to “area intersections” etc, but for now this will do exactly what I need. Excellent.
nineGradens | 2019-07-15 08:43
Also, as it turns out, test_move appears to work okay for imagining object A in some hypothetical location, but is not so hot if we are also trying to imaging object B in a hypothetical location/configuration (at least, as far as my experiments can tell).
There is potentially some scheme that can be hatch involving figuring out their relative locations after the transform, and then using that as your primary transform… But then rotations must also be taken into account, and at that stage you are kludging together far more than this function in intending. Hmmmm…
Is there any way to force the collision detection engine to recalculate things?
nineGradens | 2019-07-19 18:08
I could have sworn there was a way to make the physics engine update when you wanted it. Maybe I was thinking about a different part the engine? Then again, even if you could make the physics engine arbitrarily update, the number crunch would probably give you quite a performance hit.
Ertain | 2019-07-19 20:29
Not too worried about a performance hit.
I’m working on Procedurally generating things, and am not planning to do this “Live”, as such. What I AM worried about is succesfully having the the game engine consider “hypothetical” situations, or successfully playing animations that have been generated on the fly, etc.
So far, neither of those things appears to be working. Oh well.
nineGradens | 2019-07-19 20:56
Would be nicer if you could create a mathematical model which could test these situations, and have them play out. The problem is, that’s very complicated. As for playing animations which are created at runtime, well, you may have to create a system where you can anticipate many forms of animation, and have responses to those animations.
Ertain | 2019-07-19 21:15
Yeah- If I wanted to build an entire mathematical model I’ld just build my own engine from scratch.
Hell that IS what I did last time I was working on this project… but using an official engine has many advantages… only trouble is some of it being a black box, such as collision rules, and “when does the engine realize that you’ve modified an animation?”
nineGradens | 2019-07-19 21:24
What have you read with regards to the animation? I haven’t read the documentation on animation, but with the new animation system, it may be a bit more granular.
Ertain | 2019-07-19 22:14