Page 1 of 1

Entity collision with another unknown entity is posible?

Posted: Fri Jan 05, 2024 7:53 pm
by minimy
Sorry for my ignorance but looking at the documentation I can't find anything like it.

Let me explain: Is it possible to know which entity 'A' collides with if there are 200 entities in the environment?
Something similar to entitycollided= EntityCollide(A,#PB_Any)
Why EntityCollide(A,B) needs to specify who B is.

Thank you!!

Re: Entity collision with another unknown entity is posible?

Posted: Fri Jan 05, 2024 9:11 pm
by DarkDragon
You can store all entities in a list and iterate through that to check for collision.

Re: Entity collision with another unknown entity is posible?

Posted: Fri Jan 05, 2024 9:58 pm
by minimy
DarkDragon wrote: Fri Jan 05, 2024 9:11 pm You can store all entities in a list and iterate through that to check for collision.
Hi DarkDragon, thanks!, may be a solution.

Re: Entity collision with another unknown entity is posible?

Posted: Sat Jan 06, 2024 2:35 am
by miso
Is it possible to know which entity 'A' collides with if there are 200 entities in the environment?
In purebasic you can count the occuring collisions at any given time. World physics must be enabled, entities must have bodies.
The official examineworldcollisions.pb example might be helpful.

Examineworldcollisions counts the collisions and returns false, when there are no, any other if there is one or more to check.
Using Nextworldcollision() you can iterate trough the list of collisions created with the examine.
First and Secondworldcollisionentity() get the participants of the examined collision.

Code: Select all

If ExamineWorldCollisions(#False) ;False here means, we do not need extra data for the collision, like normals
        While NextWorldCollision()
          entityA = FirstWorldCollisionEntity()         ;These two are colliding in this collision
          entityB = SecondWorldCollisionEntity()
        Wend
EndIf
Bear in mind, that there are some transformation bug, that never had been fixed.
When you create a game object for physics in a modeler, or a mesh on the fly: create it centered around origo 0,0,0
If you don't, your simple physics bodies (cylinders) won't be in sync with your entity. Your compound objects will be, but the center of mass will remain at 0,0,0.
( the last can be used to create an all-the-way-up weeble wobble as a feature, since there are no command to set the center of mass, only to get)
Static objects shall be fine. If any given time you have doubts, use:

Code: Select all

WorldDebug(#PB_World_DebugBody)
PS: I wish you luck with your project, hoping i have helped a bit and did not say too many stupid things...;)

Re: Entity collision with another unknown entity is posible?

Posted: Sat Jan 06, 2024 2:58 pm
by minimy
Hi miso, thanks again for your time and help.
Is exactly the answer i was looking!!!
PS: I wish you luck with your project, hoping i have helped a bit and did not say too many stupid things...;)
:lol:
Yes your help is really appreciated!
Master you never say stupid things.

Thanks for help and when finish my game i will send a link to test the game.
Have a happy and nice day!