Hey I represent Hypnotic Ants studio, my name is Marcin
and I'd like to present you our
VR Interaction Pack
this pack contains a few examples - commonly used examples
that you can use in your game
everything is ready to use
and this tutorial will cover a few parts.
simple interactions
advanced interactions
canceling
sliders, cranes and levers
these are the most advanced examples
buttons which don't use physics interactions
and also complex objects
that contains more interactive components
and the folder structure
that you should know is as follows
blueprints directory
which contains the most important blueprints
example interacties - these are blueprints that we placed on a map
you can leard from them a lot
there is an example map
our materials
meshes, all of them
and textures
have fun!
let's begin with operation modes
we can operate in this demo level with VR mode
it's preparedfor HTC Vive device
on the other hand you can control it by gamepad or mouse with keyboard
and to select which operation mode you're interested in
you have to change gamemode
there are two prepared game modes
VR game mode, when you select this game mode VR character is used
then hit play with VR preview
if you want to use gamepad or keyboard and a mouse
please chose gamepad game mode
then you'll notice that gamepad character has beed selected
and of course select play mode to selected viewport
or just regular new editor window
the most important objects are
BP_InteractionsController
this is the blueprint that contains motion controller that talks to HTC Vive device
Also this actor, two of them actually are used by BP_VRCharacter
which is used in VR mode
and another one is used in BP_GamepadCharacter
which is a little bit tricky because
we're using the same code paths for VR and gamepad operations
which gives huge profit, because there is less code
and less features that can be bugged
the other important actor is BI_Interactive, it's an interface
this interface has to be implemented on all actors
that wants to be part of some interaction with BP_InteractionController
so this controller scans for overlapping actors
asks them: Hey do you implement BI_Interactive interface ?
if yes - its methods are used
first of all interactive actor can have more than one component
and only few of them can be interactive
for example a handle
this is a good example
pickable complex
only this pickable center can be grabbed by hand
and those 2 cylinders can't
this method returns true if interactions controller finds component that is interactive
and then if this component is interactive
tohse two methods can be used
OnInteractionActivate and OnInteractionDeactivate
you can use them to for example highlight an object
let me show this, gamepad gamemode and selected viewport
this is white glow - interaction activate and deactivate
you can handle this as you want
each interactive object can handle this different way
so it depends on you
the if you want to begin real interaction
OnInteractionStart and OnInteractionStop methods have to be implemented
so again, it depends on interactive object
how it would handle interaction
if ti wants to be grabbed by physics handle or if it wants to execute some action
all implementation has to be done here in this method
in the interactive object
for example
if I use slider
interactive object tell us there is a physics constraint
interactions controller has no knowledge about interactive object will behave
this is pretty flexible
the other example is a lever
it's just another configuration of components
lever blueprint decides how to consume physics input
another interesting example is a button
there is no physics interaction but button has logic that controlls press and release actions
you'll notice this when we'll analyze blueprints
interaction cancelling
sometimes there is a case when
an object held by hand
wants to cancel interaction
and to do this properly this object should implement WantsInteractionCancelled method
which is a part of BI_Interactive interface
the last method that you have to know
as long as this metod returns false
an interaction can last forever
when held object or interactive object decides to cancel interaction
it could return true here
an then
interactions controller
this one
interactions controller... will know that interaction has to be cancelled
and calls StopInteraction method
here
this is how it works
I'll grab ths ball and it will decide to drop itself after five seconds
interaction cancelled
the same with this slider
in comparison to the regular one
can be controlled from pretty far distance
but this one
will cancel as soon as I make a step back
it depends on you, how you will implement this
simple picking
all of those four tables are filled with tools
that are created with one blueprint template
it's BP_PickableSimple
but before I show you an implementation
let's focus on the difference
I'll start this in the gamepad mode
you have to notice that this will work the same way in VR mode
the first one has no constraints
as you can see
grab location is custom
also rotation is custom
this tool can rotate freely
the other one where you can attach to any place on a tool
but rotation is atached to the controller
the other one
has also no constraints
but the physics grab is soft
it's like a spring
and the last one
also soft physics grab
but rotation is snapped to controller
let's move to implementation
the first common thing is that OnInteractionActivate
when object is activated
we change GlowActive parameter in material instance
this causes the material to glow a litle bit
on the other hand, when it's deactivated, we change it back to zero, so it gets natural color back
IsInteractiveComponent
we want to interact with static mesh component
this is the only one mesh that is interactive here
so we have to compare
if given component is equal to static mesh
we would like to return true
to tell interactions component
hey this is the component that we want to interact with
InteractionStart
this is a PhysicsGrab method call, the most commonly used method for interactions
and there is some configuration here
each of those tables (tool tables) use different options
you have to just track actors in the scene
and check what options are chosen here
if this is soft grab and snap type SnapToController
NoSnap and SnapCustom will be clarified in another video
InteractionStop
happens when the trigger is released
then we want to release physics grab
and of course, WantsInteractionCancelled
returns always false, which means that this actor don't want to cancel interaction at any time
advanced picking
we have three another examples
let me introduce how they works in gamepad mode
it would work the same way in VR mode
the first one is custom grab location and no rotation snap
each of those three objects has defined grab location
I can try attach to this object at any point and it would snap at only one location
of course rotation is free
additionaly you have to notice that grab location is defined with a vector
so you can change it in an editor
ok, next one
custom grab location and rotation snap to controller
this is a little bit of a mix of the previous configurations
because grab location is still defined by vector location
but rotation is controlled by motion controller
so there is no free rotation
ok, and the last one
which is a connection of a previous two examples
there is always defined location and defined rotation of the grab
so this is the best option if you want to hold a bow or some pistol or some other weapon
physics interaction and other options
all interactive objects use physics grab
with different parameters
those parameters were detailed when I talked about those keys and advanced picking
it's the same method for slider, crank and lever
but there is small difference in a button
which don't use physics interaction
this time I'd like to talk about buttons
the difference is that OnInteractionStart method
don't call PhysicsGrab method from interaction controller
but implements its own logic
OnButtonToggle
which in fact is just a simple timeline that moves static mesh with SetRelativeLocation method
let's talkabout complex picking and complicated objects
for example this one
contains a few components
but only one is interactive - PickableCenter
this feature is implemented here
IsInteractiveComponent method
if given component is a PickableCenter, he interaction is possible
so that OnInteractionActivate will be called for this component
it would be PickableCenter
and if user decides tu push the trigger
this component will be passed also here
how it works ?
as you can see actor reacts only when I intersect with PickableCenter
on the other hand, another example is a bit more interesting
this pot has been built of 3 actors
the first type is pickable hand
with just a simple physics grab
so there is nothing more to tell about it
and another part is BP_Pot
which is just a simple static mesh
that simulate physics and has gravity enabled
the difference between those is that here we have three actors
and here we have one actor with three components
but if you try to build one actor with two interactive components
that simulate physics, something wierd can happen
it's much easier option to build those complex scenarios from for example three actors
and connect them with physics constraint actor
configured to lock everything
as you can see
we have two of them
left hand and right hand
let's check how it works
pretty nice
I can also grab this pot with two hands
to do this I'll need o switch to VR mode
wait a second please
let's move to example part
this time I'll show you how to create just a simple interactive object with properties like this key
and it would be a ball
I'll start with creating just pure blueprint
this blueprint don't need to derive from any specific class
it could be an actor, it could be your class, it could be a pawn
there is no base class requirement
the only one requirement is that this blueprint has to implement our interactions interface
let's move to class settings
choose our interface
BI_Interactive
as soon as you do this
some methods will appear here
and what we'll do next is to implement those methods
now we have to define: How this object wants to be handled ?
again - this is the major rule behind our system
interactions controller (motion controller) that you keep in your hand
don't want to know how to handle objects
if this would be doors or weapon or something else
interactive objects has to implement this on their side
this gives you a lot of freedom
let's begin with some static mesh
with hypnotic sphere
default parameters are ok
this is how it looks like
let's begin with our methods
WantsInteractionCancelled
we don't want our ball to cancel interaction so this should return false
IsInteractiveComponent
the only one interactive component in this actor is static mesh
so when interactions controller asks: Hey is this your interactive component, you wan't to say Yes
OnInteractionActivate
this is the place where glow material parameter was changed
this time we'll make it differently
or actually we can use this component, it would be the same as this one
SetWorldScale3D
let's make it bigger, just a little bit
ok
and when activation stops
OnInteractionDeactivate
let's get back to regular size
last two methods are here
OnInteractionStart
what do we want to do when player press trigger
we want to grab this object by physics handle
there is method prepared for this operation
component the same as previously
this could be soft
we want location SnapToController
so this field can be left default
and rotation also SnapToController, so we don't have to fill this
what has left ?
I think that's it, we can try to play
no, sorry, OnInteractionStop
what happens when user release his trigger ?
we want to release physics grab
and that's it
let's test it
I forget about most important
we need to place it on the map
LOUD SOUND WARNING (htc vive mic)
as you can see it changes it's shape when I
intersect with static mesh
and when I press my trigger
oops... it's not working
let's check it out
it's not working because I forget about one detail
this component has to simulate physics
let's check it one more time
activation, yep
interaction, yes
and we have ball
pretty easy
thank you!
Không có nhận xét nào:
Đăng nhận xét