Entity collision with another unknown entity is posible?

Everything related to 3D programming
User avatar
minimy
Enthusiast
Enthusiast
Posts: 619
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Entity collision with another unknown entity is posible?

Post 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!!
If translation=Error: reply="Sorry, Im Spanish": Endif
DarkDragon
Addict
Addict
Posts: 2345
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: Entity collision with another unknown entity is posible?

Post by DarkDragon »

You can store all entities in a list and iterate through that to check for collision.
bye,
Daniel
User avatar
minimy
Enthusiast
Enthusiast
Posts: 619
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: Entity collision with another unknown entity is posible?

Post 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.
If translation=Error: reply="Sorry, Im Spanish": Endif
miso
Enthusiast
Enthusiast
Posts: 466
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: Entity collision with another unknown entity is posible?

Post 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...;)
User avatar
minimy
Enthusiast
Enthusiast
Posts: 619
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: Entity collision with another unknown entity is posible?

Post 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!
If translation=Error: reply="Sorry, Im Spanish": Endif
Post Reply