Hey Guys and Gals,
I am in the process of prototyping ideas and would like to create a rolling ball that leaves a paint trail behind it. Ideally something that is permanent until erased by restarting the level. I am using the rolling ball sample project, but i have no idea where to start going about this idea. Any help would be greatly appreciated!!
Looking for the same thing
Check this vid
With a bit of tweaking, something like this should work:
Create a custom CanvasRenderTarget2D blueprint. On event receive update, it should use a draw material node, to draw a brush material. Create variables to supply to the Render Material, Screen Size and Screen Position inputs, and optionally Rotation and Pivot Point.
Create an actor from each static mesh you want to be painted.
Make sure the material for each static mesh you want to be painted includes a texture parameter that can use an instance of the CRT2D, set the default to a black texture.
To save memory, wait until the first time the object is hit by the ball to create a dynamic material instance of the static mesh’s material. Then create an instance of your CRT2D. Get the bounds of your static mesh, and use that to scale the resolution of the CRT2D when its created. Set the appropriate texture parameter on the dynamic material instance to the CRT2D. Set the material of the static mesh to the created dynamic material instance.
In your ball’s blueprint, On Event Hit, pass the hit result to a Find Collision UV node, this will be the center of your brush. You’re going to need a second line trace to determine the size of your brush on the painted object. Consider the vector between the location of the ball’s center and the hit event. Find a second vector, parallel to that one, where the distance between them equal to the radius of your brush. Do another line trace along that vector with the same static mesh. Find the UV of the second hit result.
Use these to set the screen size and screen position variables in the hit actors instance of the CRT2D. Update Resource targeting the CRT2D to draw your brush material.