Gameplay & Collision
On this page:
1. Query Paint Collision
Use this node to quickly find out whether the pixels around a world location carry any collision tag of interest, for a given mesh. If a matching collision tag was found, this function returns true, otherwise it returns false.
This allows you to build gameplay systems that react to painted areas. Eg: Pixels carrying damage for A.I. (i.e. traps), behavior cues (eg: telling the A.I. to jump), Portals (for projectiles or characters to pass through), etc. Collision tags are created for pixels at the time of painting effects (see Paint Functions)
For complex gameplay scenarios such as evaluating multiple collision tags with filters/constraints, you should use Query Paint Collision Multi instead.
For Blueprint users:-
- This node is available in the “Don Mesh Painter” category on your context menu.
- Expand the dropdown at the bottom of the node to view all parameters
For C++ users:-
- This function is available in UDonMeshPaintingHelper::QueryPaintCollision
- #include “DonMeshPaintingHelper.h”
Param |
Description |
Type |
Primitive | Any primitive (mesh/landscape-component) for which paint collision is to be tested. Typically you will supply this via generic collision events without knowing the exact primitive yourself. | UPrimitiveComponent* |
Collision Tag | The collision tag to look for. Remember to use exactly the same collision tag you passed into the system earlier in the Paint Stroke node! | FName |
World Location | The world location on this primitive where collision is to be tested. | FVector |
Minimum Paint Blob Size | This is the minimum blob/collision size this query needs to succeed. Eg: An A.I. may query for a Portal of a certain minimum size to ensure it can believably pass through. | float |
Collision Inflation Scale | Scales the size of the painted collision used for evaluating this query. Typically the correct place to do this is while painting the stroke itself as you have more context of the overall effect there. | float |
Collision Inflation In Absolute Units | Collision Safety Net. Inflates the painted collision in world-space units. Very useful for projectiles, etc that need additional margin for believable collision effects. | float |
2. Query Paint Collision Multi
Execute complex collision queries across multiple collision tags with support for filters, bucketing of duplicate collision tags by distance brackets and more. Returns true if any matching collision was found, along with the first collision query that successfully matched your collision criteria.
This allows you to orchestrate complex gameplay scenarios such as allowing A.I. to react differently to painted areas depending on their size/etc. The best example for this is the sample project’s “Character Interaction – Floor Pit” (Item 3 in Paint Collisions) where players are allowed to dig holes of different sizes on a wooden floor and the A.I. responds to small holes by jumping over them and to large holes by simply falling into the pit.
This is achieved by creating multiple queries for the same collision tag that each specify different minimum collision blob sizes that they’re interested in.
Here’s what the node looks like:
And here’s what the collision tag query structure looks like:
For Blueprint users:-
- This node is available in the “Don Mesh Painter” category on your context menu.
- Expand the dropdown at the bottom of the node to view all parameters
For C++ users:-
- This function is available in UDonMeshPaintingHelper::PaintStrokeAtComponent
- #include “DonMeshPaintingHelper.h”
Param |
Description |
Type |
Primitive | Any primitive (mesh/landscape-component) for which paint collision is to be tested. Typically you will supply this via generic collision events without knowing the exact primitive yourself. | UPrimitiveComponent* |
Collision Tags | List of Don Paint Collision Queries. Each query has configurable collision filters in it. You can create multiple queries for the same collision tag! The sample project uses this technique to make A.I bots jump across small-sized holes and fall into large-sized ones. [Blueprint tip] drag a wire from this parameter, type “Make Array”, and then “Make DonPaintCollisionQuery” to rapidly setup your queries. |
FDonPaintCollisionQuery |
Out Collision Tag | The first matching collision query that succeeded. Use this to drive gameplay decisions by testing which collision tag succeeded, and also which specific filters it passed with. | FDonPaintCollisionQuery |
World Location | The world location on this primitive where collision is to be tested. | FVector |