UFO shall pass around a object while chasing...

Hi

I have a UFO which shall pass around a object while still pursuing my ship. I can’t solve this without trembling UFO. Here is what I’m doing:

1.UFO pursues my ship (solved, no problem here).

  1. UFO has a invisible, sensor circle physics body which detects collision (so that the UFO doesn’t approach too much)

  2. When the circle collides with the object some math is done to identify the objects boundary angle (e.g. the tangent to the circle).

  3. The circle (and UFO) moves in one direction (the shorter to my ship) along the object

  4. If the collision is ended the pursue continues.

So far the theory. But collision is only recognized once, then I have to move the circle/UFO away from the object, to allow a next collision which enables to correct the path around the object. But this results in a trembling: The UFO aproaches, flies away, aproaches, flies away, etc etc.

Is there a concept that would allow the UFO a smooth passing around a object?

Thanks for your help and sorry for my english…

Olivier

You might be better off with non-physics collision detection, so that you can continually check whether either object is overlapping.

https://coronalabs.com/blog/2013/07/23/tutorial-non-physics-collision-detection/

Hi Olivier,

What is the “other object” that the UFO should not collide with? Shouldn’t you just use collision filters to ensure that the UFO ignores collision with that object?

Also, if the UFO is simply “chasing” the ship, have you considered joining the two objects with a touch joint? That is often a simple method to have one physical object follow another, and the joint parameters can be adjusted to determine how fast the following object reacts to the ship changing directions and so forth.

Best regards,

Brent

Thanks both for your replies. Maybe I couldn’t write it enough clear. The problem is how to move the UFO around a obstacle between it and my ship. I attach a picture showing the problem. How would you solve this?
Thx again, Olivier

Hi Olivier,

I still think you could solve this with a touch joint. Just make the “circle around the UFO” not a sensor (a regular dynamic body, but it only collides with the obstacle by use of collision filters AND it has no bounce ). Then, the touch joint will continue to attempt to bring the UFO toward the ship, but because the UFO’s “circle” is colliding with the obstacle, it won’t be able to until path is clear… only then will the joint pull the UFO toward the ship.

https://docs.coronalabs.com/guide/physics/collisionDetection/index.html

https://docs.coronalabs.com/guide/physics/physicsJoints/index.html

Brent

Brent, thanks very very much for your help, this is a elegant solution. I’d never figured this out by myself…

Greetings

Olivier

You might be better off with non-physics collision detection, so that you can continually check whether either object is overlapping.

https://coronalabs.com/blog/2013/07/23/tutorial-non-physics-collision-detection/

Hi Olivier,

What is the “other object” that the UFO should not collide with? Shouldn’t you just use collision filters to ensure that the UFO ignores collision with that object?

Also, if the UFO is simply “chasing” the ship, have you considered joining the two objects with a touch joint? That is often a simple method to have one physical object follow another, and the joint parameters can be adjusted to determine how fast the following object reacts to the ship changing directions and so forth.

Best regards,

Brent

Thanks both for your replies. Maybe I couldn’t write it enough clear. The problem is how to move the UFO around a obstacle between it and my ship. I attach a picture showing the problem. How would you solve this?
Thx again, Olivier

Hi Olivier,

I still think you could solve this with a touch joint. Just make the “circle around the UFO” not a sensor (a regular dynamic body, but it only collides with the obstacle by use of collision filters AND it has no bounce ). Then, the touch joint will continue to attempt to bring the UFO toward the ship, but because the UFO’s “circle” is colliding with the obstacle, it won’t be able to until path is clear… only then will the joint pull the UFO toward the ship.

https://docs.coronalabs.com/guide/physics/collisionDetection/index.html

https://docs.coronalabs.com/guide/physics/physicsJoints/index.html

Brent

Brent, thanks very very much for your help, this is a elegant solution. I’d never figured this out by myself…

Greetings

Olivier