Hand Functions

Press Button to open door



Set Overlap collision on VR Pawn:
Add Sphere collision on both left and right controllers, scale down the size to fit the collision influenced area:
image.png

Make button:


Create a BP actor, called Button
Make 2 static mesh with different mesh and materials:
image.png
Put it in the scene
Back to viewport, add box collision child under button, adjust its size as shown (Z axis should be thin enough, just barely cover the button service)
and then create a click for event graph:
image.png
image.png

Now should the VR controller on the box collision, button should be pressed, but the button won’t returned back after pressing once
To modify:
add is pressed boolean vairalble, and extend the graph:
If overlap on box, see if the button pressed, if true, no further action; if false, will do the pressing
image.png
To make the button can be pressed again, extend the ending graph:
image.png

Make Door:


Create a BP actor called Door
image.png
Add custom event, name as Opening
Test the movement by connect beingplay node as below, play by simulation (once the move as expected, remove the node)
image.png
Connect opening event node to replace event beginplay
image.png

Back to button BP event graph, 1st move component to node, insert below:
image.png

To make the door close back after open when press the button again:
Back to door BP, add flip flop and change + to - in move:
image.png


P.S. The button don’t know why can’t bounce back sometimes after press, this method from other tutorial to create another button design:


After create button BP,
add Arrow component in veiwport, rotate 90
Don’t know why button cannot move the location, so has to move the arrow and Body to align them together, but then it’s no longer in centre of defaultsceneroot
image.png
Go to construction script, add float variable buttonOffset, default value 100
(to control how far the button be pushed down)
image.png
Then in event graph:
image.png

(this method also doesn’t work)


Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.