I’m trying to reproduce the painting mechanism from Tilt Brush as an exercise. I know that splines are probably best suited to this task. I was wondering if anyone could by any chance nudge me in the right direction - say, if you add a spline component to the motion controller that only … activates upon trigger press? I’m new to working with splines, so any guidance at all would be much appreciated.
Also curious if you can control the spline’s color while in the same session, and if you can, say, plan for the splines to disappear after a certain amount/size has already been created.
You should not add a spline component to the motion controller, but rather spawn a new BP containing a spline component at the current position of the motion controller as soon as the user presses the “draw” button. Then you track the position of the motion controller as long as the button is pressed and add points to the spline. Finally, when the button is released, you terminate editing the spline. You can also associated a timer to each spline BP so, after a given time, it will Destroy itself.
So I built out the spline BP and am spawning them at the location of wherever the motion controller is when I press the assigned button.
I am encountering some difficulty “drawing” it, however. By that I mean - tracking the position of the motion controller and adding points to the spline. I tried copy, pasting, and adjusting the spline that controls the teleportation arc in Unreal’s VR template, but that did little good.
Is the tracking of the position of the motion controller and adding of the points to the spline going to take place primarily in my motion controller pawn or in the construction script of the spline BP? I know I’ll have to make use of branches/booleans to determine the whole “if held” thing, but if you could offer any more guidance on how to track the motion controller and add points to spline that’d be brilliant.
PS - loved your two most recent videos! Been waiting forever for someone to cover that kind of thing. Cheers.
Hey Marco - not quite, if you can see the sort of question I asked in the message right before I attached the photo, I’m a little unsure with how to approach the tracking of the motion controller (while “draw” button pressed/held) and the adding of the points to the spline. Would you recommend this functionality be built out in the construction script of the spline BP (above) or in the motion controller pawn where I have the “draw” input event functionality.
Basically you you need to track whether the “draw” button on the controller is pressed or released. Let’s say you use the trigger button.
You add an event for that trigger button and if Pressed you set a bDraw variable to true, when it is Released you set it to false. At the same time you set the bDraw variable to true, you create a new spline at the current position of the motion controller (GetWorldPosition). When the button is released you will terminate the spline by adding one last point at the current position of the motion controller and the closing mesh.
On Event Tick, while bDraw is true, you get the current world position of the motion controller and add a spline point based on it. Then you add a mesh along the spline to represent the paint trait.
This is pretty much it. I didn’t try it myself, so there could be some nuances to take care of, but it should work.