Also, this does not work with level geometry (walls, floors, ceilings, etc). Sorry, but there's no way around that. This is actors only.
Now onto the good stuff.
This is code for cylindrical collision, for example.
Code: Select all
override bool CanCollideWith(Actor other, bool passive)
{
if (!passive)
{
if (!other) return false;
return (Distance2DSquared(other) <= (other.radius ** 2));
}
return true;
}
Bear in mind the following:
- CanCollideWith activates last, after all the other internal collision checks pass and find an actor to collide with. I.e. all the THRU flags (species, ghost, NOINTERACTION, etc). If any of those happen to dismiss the actor as non-collideable, naturally the function won't trigger.
- The function only triggers if the two actors are actually touching.
- 'passive' means the actor that's NOT doing the collision check.
- It's unclear if normal actors are always forced above/below standard geometry if trying to force move them below ground or above the ceiling.
- There are plenty of caveats to using this -- sliding along actors for one goes down the toilet, mostly. You'll have to come up with your own bouncing algorithm of things that impact it.
- The actor's box is still a square, and is still AABB. You are only changing collision with other actors.
- This is for actor to actor collision only.
- This doesn't affect map geometry.
- This doesn't affect map geometry.
- This doesn't affect map geometry. Just to make sure this note's clear as mud.