This course will teach you about one of the most important aspects of VR, how you interact with a VR world. Virtual Reality is completely different from an on screen app or game. You are completely immersed in a VR world, so it doesn't make sense to interact only through buttons or menus. You will get the most out of VR if you can interact with the world just as you would with the real world: with your natural body movements. You will learn about the basic concepts and technologies of VR Interaction. You will then get hands on, learning about how to move around in VR and how to interact with the objects in your world. The course will finish with some advice from experts on VR interaction design and you will do a project where you will get real experience of developing VR Interaction.

SZ

Very good course showing how to use VR interaction techniques. Thank you!

HR

Sep 03, 2018

Filled StarFilled StarFilled StarFilled StarFilled Star

This is really a grate course to learn about virtual realty

从本节课中

Interacting with Objects in VR

Welcome to Week 3! This week, we will be looking at interacting with objects in VR. We'll cover topics such as interacting with objects within reach, hyper-natural interaction, and magic interaction. We'll then move on to physics interaction, and how this works in VR.

教学方

Dr Sylvia Xueni Pan

Lecturer, Department of Computing

Dr Marco Gillies

Senior Lecturer

脚本

[MUSIC] So here we have a Unity scene that we've been building over the last few weeks of this specialization. And if I run it, we can have a quick look around if I tilt my headset. I'm currently using an Oculus Rift. So you may have noticed I made this ping pong table. And of course, if you got a ping pong table, you want a ping pong ball or a ping pong bat, and that's what we're going to do today. And because we don't just want a ping pong ball and ping pong bat that look nice, but that one we can interact with and we can play ping pong with, then we're going to create that with some physics. So let's start by creating a ping pong ball. So Game Object > Create > Sphere creates a white sphere, which looks quite a lot like a ping pong ball, other than it's huge. So I'm going to scale it down. I'm going to type in to the scale transform up here, so that I'm sure they're all the same size in all directions, and I'm going to type in 0.1. That's actually pretty big for a ping pong ball, to be honest, but that's okay. It means we can see it better. So I'm going to move it to make sure it's over the table. I don't want it to fall on the floor. And it's an object, it's got a collider, which is a key part of physics. But the thing to really make it respond to physics is going to be the rigidbodies. So I'm going to go to Add Component here > Physics, and I'm going to select Rigidbody. And it's going to use gravity, which is really all we need, and we'll just see what happens when I add that. And you can't really see it. It's fallen off the ping pong ball, so that wasn't particularly interesting. I'm going to fix that in a couple of ways. First off, one of the reasons we didnt see much is that the camera's looking in the wrong direction. So that's how we set it up before, but there's nothing stopping us turning the camera around, so let's turn the camera to look at the ping pong ball. And in a previous example, oops. This is why I normally actually just type in, rotation's 270. There we go. And we can see, well, that's already happened. The other problem is that our camera is fading in on start. That's something I added to the VR mode. It's a nice thing, but we're still not actually seeing much. It's just falling straight away, which is fair enough. I mean, we can probably lift it up a little bit higher and up a bit, and you might actually see it fall. There we go. But it's not doing much. It's just falling like a dead weight. That doesn't look much like a ball. What's going wrong? Well, the main problem is it's not bouncy. So in order to fix that, we need to make the ball bounce here, and the thing we need for that is what's called a Physic Material. And I'm going to go to Assets > Create > Physic Material. Now to be honest, I don't really know why is doesn't have an s in the end of Physic. That might be referring to some sort of deep, physical thing, or they might, long ago, have made a typo. I have no idea. But I'm going to create new Physic, not Physics Material, I'm going to call it Ball. And then when I select my sphere, which I'm actually going to rename Ball, so I'll know what it is. And I'm going to go to its Sphere Collider, and the Physic Material is attached to the Collider. So I'm going to click on the little circle by it and select Ball, and so it's now got a Physic Material. I can look at that, and I'm going to change the bounciness. Now I want it to be really bouncy. Let's make it 0.9. One is the maximum, I think. It might not even be. What happens if we have a bounciness at 2, who knows? Let's watch what happens. And it bounces, fantastic. Now, the bounciness depends actually not just on the ball, but the thing it's colliding with. So let's have a quick look at what it's colliding with. It's colliding with the top of the ping pong table. And we can see here that it has a box collider, it actually has a rigidbody, which is kinematic, so I'd put that on before. Now, what that means is that it responds and interacts with physics, but because it's kinematic, it doesn't actually move itself. It doesn't fall under gravity. We don't really want the ping pong table to move. We just want things to bounce off it. So it's got pretty much everything you would want. If it didn't have the collider or all of it rigidbody, the ball wouldn't be bouncing off of it properly. So that's how we need to set it up. I'm going to create a new physic material for that. Create > Physic Material, and call it Table. There we are. And go back to the table top and select that Physic Material. And again, we need to edit that to give it a bounciness. I'm going to make it quite so bouncy. I'm going to make it 0.4. And let's have a look at what happens. It bounces around a lot. Great, so we have a bouncing ball. That's physics interaction. And that's great in itself, but let's have a bat as well. I'm going to move the ball, and I'm going to create a bat. Now this bat, it's still called sphere. I must have renamed it in play mode and the changes didn't get saved. Now, a bat isn't really a primitive object, but I'm going to to make it out of two primitive objects. I'm going to create a compound object, which I'm going to start with, not inside the Ball, but creating an empty game object, and I'm going to call that empty game object Bat. And inside, I'm going to create a cylinder which is going to be the head of the bat, and another cylinder which is going to be the handle of the bat. Now let's go and have a look at them. Now these two are, they're both in exactly the same place. It's not really what you want, and they're exactly the same shape. Now, first off, let's move the bat down a lot and near the table. It was created next to the ball, which is not a bad place for it to be created, but I want it a bit near the table. The head and the handle are at position 0.0 relative to the bat, which is a good starting point. So we don't want our sub-objects of the compound objects being too far away from the main object and transform itself. Now the first thing I'm going to do is I'm going to take the head and I'm going to scale it. So I want it to be a bit wider, so I'm going to do x and z. But it's very flat, so I am going to make the y tiny. So that is a round cylinder. That looks kind of good. And I am going to push it a little bit this way, so it's going to be at one end of the of the bat itself. Now, I don't just want a white ping pong ball bat. I think they should always be red. They look good when they're red. So I'm going to create a material for it and call it Bat Material, and I'm going to drag that onto the bat, and then we can make it red. If you're wondering about any of these things I'm talking about, you can go back to my lectures earlier in the specialization on graphics. Now, let's sort out the handle. I mean, the bat looks pretty good, but the handle's completely in the wrong place. So I'm going to start by rotating it. No, not that way. Sometimes, I just do trial and error to rotate. Do I rotate by x? Do I rotate by z? It doesn't really matter. Just trial and error and see which one direction you want. That's a little bit more like it. So I've rotated it and moved it down, so it's kind of in the right direction. And now we've just got to make it a little bit smaller. This time, I'm going to use the widgets because I just want to do it by eye, really. It's not that critical. And there we go. Quite a nice looking bat. Now all we need to do is add a rigidbody to the bat. Now, the bat doesn't have a collider. It's very important that anything with a rigidbody has a collider. So is it a problem that I haven't got a collider? Well it's not, because actually, the two children have colliders. Each one of these has a capsule collider. That's because it's been created with one because it is a primitive. Okay, so let's have a quick look what happens. Okay, something weird has happened. It's kind of sitting on end. Why is the bat not lying flat now? Let's have a look here. What's going on? Well, what I'm going to do is I'm going to select the head. Capsule collider, I'm going to do edit that. And if you can see, it's round. Why is it round? Well, that's because cylinders, by default, have what's called a capsule collider. It's not shaped like a cylinder, it's got kind of round bits at the end. And if you make it really flat, and if you look at the collider for the handle, that's sort of, kind of sensible. It's got a capsule-y bit, which you can just about see here. It's rounded, but it's long and thin. And the capsule makes sense. For a very flat cylinder, it doesn't make sense to have these rounded bits, so I'm going to get rid of the capsule collider. I'm going to remove the component and I'm going to add a component, Physics > Box Collider. There we go. It worked. It instantly fell. Except I'm in play mode, so it won't have saved. So let's do that again, except in edit mode. And if we now play this again, we can see that our bat has fallen nicely on the table. So, what we've seen is that we've been able to create a simple physics object from a primitive ball. And it bounces by adding a physics material, it bounces off objects that are themselves rigidbodies, and we created something a little bit more complex. We created a bat, which is a compound object. It's got a head and a handle. More importantly, as well as the compound graphics objects, the collision objects, the colliders, are also compounds, so they've each got a different one. And we needed different colliders for the two, for the handle, which worked fine in a capsule, and for the head, which needed a box collider. So that is the basics of creating some objects with physics attached to them, and you can see they are already doing interesting, interactive things. [MUSIC]