PHYSICS Collision detection problem with Windows build and simulator...

I have a tower defense game I want to build for Windows. It is a mobile game right now and working fine. BUT with the Solar2D Simulator and a final Windows version there are some strange collision problems. In detail:

The game has paths where creeps are moving on. You then can freely drag towers on the screen and a collision detection prevents you from moving the dragged objects “over” the paths. The collision detection stops the tower and just continues when you reach (with your finger or here the mouse cursor!) a free (without path) area with your finger (here mouse) on screen again.
BUT: In the Windows build, just like in the Simulator the towers start to flicker when the mouse is moved over a path. As long as the mouse is moved over a path and the collision detection is working the tower is starting to “flicker” and shown one time where it had stopped when hitting the path and one time over the path at the mouse position.

The physics collision detection seems not to be working constantly and allows the object to be shown above another object which should not happen.

Is someone else experience this? Or does know how to fix it?

The strange part: When the game is build for Android or iOS on device it works perfectly! Just in the Simulator and a Windows build the problem is shown.

Any help on this welcome!

Thank you!

How can anyone help you without some playable unit test?

If the problem is also in sim then surely you’ve had this throughout the dev of the mobile versions?

I know it is a “hard” question without a test but I hoped for some devs who experienced something similar. Right now it is not possible to put together a working sample. I did get some info on another channel, so it seems like some others did experience similar behavior.
When I have more details I will post here.

Is it possible that this is a scale issue?

I don’t think so because it works on all different smartphones and sizes perfectly. In the Simulator it happens since one of the older Solar2D builds from about two years ago I think. Unfortunately I do not have the correct number of the build since when it started to happen in Simulator. Before it worked in the Simulator correctly also.

If you had a sample that’d have been the first thing I was planning to look into. timeScale and scale. My first thought was that there might be a bug how Solar2D handles build.settings for PC builds.

Thank you! The “visible problem” appears in the Simulator also for the mobile versions btw.
But when tested on device it works. I have to find some time to put together a test. Thx again!

I did find a solution to fix it…

Let me explain: I am dragging a weapon on screen. When the weapon is hitting a path, the weapon normally is stopped while a collision object still is hovering over the path and when it enters a “free” area the weapon is following to this free position.
So I did set the weapon position to the position outside of the path, right before the collision started. And the weapon (which still was moved by the touch listener) started to flicker over the path (one time over path, one time last position outside of path).

This behavior started around two years ago with a new Solar2D build but did not appear on mobile devices.

NOW I have added the following code in the touchListeners “move” phase:

if holdWeaponInPlace==true then 
                    myWeapon.x=myWeapon.rangeCircle.x
                    myWeapon.y=myWeapon.rangeCircle.y
                end

right behind the mover function for the weapon. (The rangeCircle is positioned on the last pos of the weapon outside of the path before the collision was detected)
This code normally was run in a GameLoop with deltaTime where it still did result in a flickering weapon.

Run in the touchListeners “move” phase it now is working again as planned…

so maybe there was a change somewhere back in a build where a gameLoop function OR deltaTime and the touchListeners phases were changed somehow??? This would explain it.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.