by Major Cooke » Thu Jul 27, 2017 11:28 am
Before starting, I must warn you that this isn't advised when using lots of actors at once. Graf has stated this may cause slowdowns, potentially. Make sure you use with care!
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;
}
I will post more in good time once I come up with them. Here's a hint though... One can go spherical if they use Distance3D instead of 2D (additional adjustments may be needed).
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.
Before starting, I must warn you that this isn't advised when using lots of actors at once. Graf has stated this may cause slowdowns, potentially. Make sure you use with care!
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]override bool CanCollideWith(Actor other, bool passive)
{
if (!passive)
{
if (!other) return false;
return (Distance2DSquared(other) <= (other.radius ** 2));
}
return true;
}[/code]
I will post more in good time once I come up with them. Here's a hint though... One can go spherical if they use Distance3D instead of 2D (additional adjustments may be needed).
Bear in mind the following:
[list][*]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.
[*][size=150]This doesn't affect map geometry.[/size]
[*][size=200]This doesn't affect map geometry.[/size] Just to make sure this note's clear as mud.[/list]