Collision Tags #2030
garrynewman
announced in
Announcements
Collision Tags
#2030
Replies: 1 comment 1 reply
-
It would be nice to have an enum for the base tags such as player, weapon, trigger, etc. Is this planned? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've spent a week or two converting the collision system to use tags. This wasn't a small undertaking because collision groups and layers have been ingrained into the engine for a couple of decades. This was definitely needed though.
The old system of collision groups and InteractsAs, InteractsWith, InteractsExclude was confusing to everyone. Hopefully this new tag based system is simpler.
The design has taken pointers from how Unreal and Unity both handle collision, and has hopefully taken the best elements of both.
Tags
Add a tag to an entity.. Tags are automatically networked.
You can see and edit which tags an entity has set in the entity inspector.
Collision Matrix
The collision matrix decides how physics objects are going to collide. There's explanation on how these rules are used on the project settings screen, so I won't repeat it here.
You can open project settings by clicking on the slider in the toolbar here..
These settings are saved in your .addon file. You can edit them while your game is running. They're automatically synchronized to any connected clients.
Traces & Player Movement
Traces don't use the collision matrix at all. I felt this separation was the best way to keep things as simple as possible. You can describe which tags should be present, which shouldn't.
You can also test a point for tags.
Traces no longer hit purely clientside entities by default. I feel this is 99% the desired situation. You can opt into hitting clientside objects using
.IncludeClientside()
on the trace.You can see which tags the trace hit by looking at
TraceResult.Tags
.. which is just an array of tags.Hammer
Some maps might need recompiling to get the new collision information - but the majority will work fine without any changes. as part of this change I changed how tool materials like playerclip work. Previously their function, which collision mode etc, was kind of hard coded into the engine. Now you can make any material add collision tags to its brushwork.
This only relates to world geometry and I've already converted all of our existing tool materials to use tags.. but this should allow you guys to make your own tool materials that specify game specific tags if you have any kind of need to do that.
Code
You're going to see some bugs with collision. I didn't make this a pain day because things mostly work. Here's what's now obsolete..
Here's an example of a bug..
sbox_0004.mp4
How do we solve this? The laser is meant to be a trigger, and it obviously isn't getting the trigger tag - so add the trigger tag. Problem solved.
Future
There's a bit more to do. I'd like to clean up CCollisionProperty internally a bit more. I'm not sure we need SolidFlags, SolidType, MoveCollide, TriggerBloat, SurroundingBoundsType. There's a lot more to be chopped out and simplified using tags, this was the first and hardest part.
Beta Was this translation helpful? Give feedback.
All reactions