Jump to content

Instant Collision Feedback


gamecreator
 Share

Recommended Posts

Is there a way to instantly know if two entities or two bodies are colliding without using EntityCollisionCallback? I'm trying to do something like this:

 

//  Move entity forward 2 spaces
PositionEntity(entity1,Vec3(2,0,0),1);

//  If it collides with something
if(EntitiesAreColliding(entity1,entity2))
{
  //  Move entity forward 1 space
  PositionEntity(entity1,Vec3(1,0,0),1);

  //  If it still collides with something
  if(EntitiesAreColliding(entity1,entity2))
  {
     //  Don't move entity
     PositionEntity(entity1,Vec3(0,0,0),1);
  }
}

Link to comment
Share on other sites

Just make your own EntitiesAreColliding function which checks from a STL map, which is populated by the EntityCollisionCallback function, if the two entities are colliding.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

The reason the engine doesn't store a list of collisions is because it can result in hundreds of dynamic allocations of memory each physics update, most of which will be unneeded.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

I'm manually checking if the character can move forward, or up a hill, or down a hill or if it bumps into a wall.

 

groundcheck.gif

 

Let's say I need to move the character over 10 spaces this frame. I first check if it can move over 1 space. If it can, I move it. Then I check the next space. So on. I think it would be a waste to use EntityCollisionCallback because I would have to pass it dozens of possible situations, each through an individual (so dozens) of entities, if I understand its use correctly.

 

I'm probably doing this the hard way though.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...