HomeVideos

Godot 4.5 Tutorial: Interaction System & Physics Doors (Backrooms Part 4)

Now Playing

Godot 4.5 Tutorial: Interaction System & Physics Doors (Backrooms Part 4)

Transcript

742 segments

0:02

We are a ghost in a shell. We can walk,

0:05

we can look, but we can't touch. To make

0:07

this a game, we need to interact with

0:09

the world. Welcome back to GDO Dev

0:11

Checkpoint. In the last video, we nailed

0:13

that VHS look. Today, we're going to

0:16

make it functional. We need a way for

0:18

the player to tell the game, I want to

0:19

use this object, whether it's a door,

0:21

light switch, or an item. Today, we're

0:24

going to build a universal interaction

0:25

system using Raycast and GDAU's tweening

0:28

engine. and we're going to learn two

0:30

things. How to bake custom grid map

0:33

tiles using CSG and how to write an

0:36

interaction system so we can open them.

0:38

Now, in a firstp person game, your mouse

0:40

cursor is the center of your screen. We

0:43

need a laser beam shooting out from our

0:45

eyes to detect what we are looking at.

0:48

Now, back in our project here, we're

0:50

going to go into our player scene.

0:53

Then we're going to go into the head

0:55

section into our camera 3D. And our

0:59

camera 3D, we're going to right click

1:00

and add a child node.

1:03

We're going to add a raycast

1:05

3D

1:07

right here. Create. And rename this

1:10

raycast to interaction

1:13

ray.

1:15

Just like that. And we're go into the

1:17

inspector with the interaction ray

1:19

selected in our target position here.

1:23

We're going to set this to zero on the Y

1:28

and then -2 on the Z. Now, if we go back

1:33

down here, we can see we have our camera

1:36

here. We have our ray cast is this blue

1:39

line here. Now, if I was a control Z and

1:42

redo undo what I did right there, you

1:45

see our raycast here is pointing down

1:48

towards the ground. Now we want it if I

1:52

Y zero, it's going to bring it up to the

1:54

middle here. And then if I redo the -2,

1:58

now we have this raycast pointing out

2:01

from our center of our camera, which is

2:04

our eyeballs. So whatever we're looking

2:06

at, that's we're going to be able to

2:07

touch. And always make sure this enabled

2:10

is true. If it's disabled, you can

2:13

disable the interaction. Turns gray. And

2:16

if it's a blue, means it's on.

2:19

It's also nice to have some sort of

2:20

reticule which also hopes helps with

2:23

motion sickness for people too if they

2:24

have something to look at in the middle

2:25

of the screen. We go to our camcorder UI

2:28

right here. We're going to right click

2:30

and add another child node, a label

2:34

right there. And we're going to rename

2:36

this label to aim dot.

2:40

Now we're going to do the same thing we

2:41

did on the record label. Now you can

2:44

just go to the

2:47

record label and the dot here. We can

2:49

copy this. Crl C and then the aim dot.

2:54

Ctrl +V.

2:56

Perfect. And if you don't remember how

2:58

to get that, remember it's at our

2:59

character map and the unit code for in

3:02

the advanced view is 25 CF. That's a

3:05

little dot here and you can copy it from

3:07

here.

3:10

After we have that dot in there, we're

3:11

going to change the aim dot

3:15

anchor full wreck. It takes up the whole

3:18

screen.

3:20

So that way when we change our

3:22

alignment,

3:23

we're going to change it to center

3:26

vertical alignment center. Now we have a

3:29

dot right in the middle of the screen to

3:31

help us aim just right where our raycast

3:33

is. or make the dot a little smaller and

3:37

scroll down to theme overrides,

3:40

font sizes. Just going to change it to

3:43

eight. A little less intrusive that way.

3:46

Go ahead and save that and take a look

3:49

at it. Go back to our world scene. We're

3:51

on the current scene.

3:53

We see a little dot in the middle.

3:56

Turn off my highlighter to make it more

3:58

visible. Now, this little dot will help

4:00

with selecting things when we get things

4:03

into the level. Now, we need to update

4:06

our input code a little bit. When we

4:08

press interact, we check the laser. If

4:11

it hits something, we ask, do we have an

4:14

interact function? First of all, we need

4:16

to add an interact function, or not a

4:18

function, but an interact setting in our

4:21

input map project. Project settings.

4:24

I'll bring back my highlighter here.

4:28

And then we go to the input map. And

4:31

then we need to add a new action called

4:33

interact.

4:35

Press enter and scroll down. An interact

4:39

function we just made or action we just

4:42

made. Add new event. And we're going to

4:45

use well, let's use E. There we go.

4:51

Press. Okay. And we also add left mouse

4:55

button. There we go. So E or left mouse

4:58

button. Those are pretty standard. Pick

5:00

up or interact.

5:03

Go and close that. Now we're going to go

5:05

back into our script and our player

5:08

script. I'll make this bigger so you can

5:10

see. Make this down. We're going to go

5:13

into our unhandled input function here.

5:18

Click that in my filter methods.

5:20

Now we're going to keep all our mouse

5:22

look and our flashlight logic. from

5:26

enter down below the flashlight toggle

5:29

here. And this is going to be our

5:31

interaction logic.

5:35

So we just need to check for an event if

5:37

the action is pressed like we did with

5:39

the toggle flashlight here. So if event

5:41

is action pressed

5:44

and we're going to check for the event

5:46

of the one we just made interact.

5:50

And if that happens, well, we need to

5:52

check if our array that we just made is

5:55

colliding with anything that has an

5:57

interact function. So if the interaction

6:02

interaction

6:04

ray, which we actually need to put in

6:06

our variables, we need to actually have

6:09

access to it. So I'm going to minimize

6:11

this. We go back into our layer scene

6:16

here and we need to get our interaction

6:20

array right here. And right in this

6:23

onready right below all our other

6:26

onreies, we're going to take this

6:28

interaction array, click, drag, and

6:31

drop. And now I have access to the

6:33

interaction array in my player. I go and

6:36

make this bigger. Scroll down back to

6:40

where we were. if interaction array now

6:43

that we have it.get

6:46

collider.

6:48

There we go.

6:51

And then once we know if it has a

6:53

collider, we can get it. We need to

6:55

store that collider. So var collider.

6:59

Then we're going to get that

7:01

interaction.

7:02

Ray get collider.

7:06

Now that we know it has one. There we

7:08

go. We don't want to try to get it if we

7:12

don't know it has one.

7:15

We get an error that way. And then after

7:17

we have the collider, we want to check

7:19

if that collider

7:21

has

7:23

a method.

7:25

Has method. Uh yeah, we'll do this. Has

7:28

method. There it is. Interact.

7:34

And if it does have that method, well,

7:37

we're going to use our interact function

7:42

that we know it has. So if a door has

7:45

the interact function, which it will if

7:47

you want it to be opened,

7:50

to say it has a locked door, you can

7:51

make it so it doesn't do anything. Or

7:53

you can change the interact method if

7:55

locked do this other thing. So I put a

7:58

little comment above that saying if the

8:01

object

8:03

has

8:06

an interact function

8:11

I could spell

8:13

call it.

8:15

So funny out this is something called

8:18

duck typing.

8:20

So duck typing.

8:23

So basically that just means if it

8:25

quacks like a duck,

8:29

it's a duck.

8:31

Now it's a programming concept.

8:35

And how the definition goes, it's an

8:37

object's suitability for a task is

8:40

determined by its behavior, methods, and

8:42

properties it has, functions, rather

8:45

than its explicit type. A lot of the

8:48

programming concepts are pretty fun to

8:50

read about. You can find a lot of it on

8:52

Wikipedia, Stack Overflow, even a

8:54

gdotutorials.com

8:56

has a whole section on it. So, if you

8:59

want to deep dive into that, there's

9:00

plenty info there. In our context for

9:03

this tutorial, well, it just means the

9:05

player's interaction raycast. It doesn't

9:07

need to know exactly that the object is

9:09

like a door, tape, or light switch. It

9:11

only needs to know the specific function

9:13

method is available.

9:15

This means we can add this interact

9:17

function to anything we want. The

9:19

monster even and we never have to come

9:21

back and change this again. Very

9:23

flexible. As long as the object has

9:25

interact function, the player can use

9:27

it. Now, before we make the door, we

9:30

need somewhere to put it. We don't want

9:32

to manually place walls with the grid

9:34

map or light can leak through and the

9:35

Z-index thing can get weird. So, we need

9:38

a specific doorway tile. We'll build

9:41

this out of one piece with use a cookie

9:43

cutter for our door shape. So the

9:45

texture stays consistent. So going to

9:47

use the CSG subtraction method. Now we

9:51

need to go to our mesh pallet scene 3D.

9:55

Make this smaller.

9:57

Okay.

9:59

Now right click the mesh palette, add

10:00

child node. It's going to be a CSG

10:02

combiner

10:04

node here.

10:06

Create. I'm going to rename this to door

10:10

frame

10:12

builder.

10:14

doorframe_builder.

10:16

I'm going to add a child node to that.

10:18

The CSG box right there. Then the size

10:23

in the inspector, I'm going to change it

10:24

to four four 0.2.

10:28

That's the same size and width of our

10:30

wall. I'm go and hide these floor wall

10:33

ceilings for now. So, we just have our

10:35

door here. And I'm add another CSG box

10:38

to the door frame builder there.

10:43

Then I'm going to change this operation

10:45

here in the CSG shape 3D from union to

10:49

subtraction. So now we have a cookie

10:52

cutter. It's going to cut a hole in this

10:54

wall we have. I'm going to change the

10:56

size for this to a door size. We use

11:00

1.25,

11:02

2.5,

11:03

and 1.0. Thick enough to cut through the

11:07

wall itself. I'm going to change the

11:09

position of this to the door spot. So,

11:12

back in our transform here, position

11:14

we're going to use zero Y0.75.

11:20

And now we have it down on the floor.

11:23

So, we have the doorway.

11:25

Great. Now, we take our door frame

11:27

builder. So, select the CSG combiner

11:30

node. What we're going to do here, we're

11:33

going to select this CSG section here in

11:36

the toolbar. We're going to bake this

11:38

mesh instance.

11:40

And now we have an instance of our

11:41

doorway. I'm going to rename this new

11:43

mesh to wall door.

11:49

Now we can hide this for now with this

11:51

wall door here right above it. And this

11:55

needs a collision shape just like our

11:56

other ones. So with the wall door

11:58

selected, the mesh, we're going to

12:00

create a collision shape and not a

12:03

sibling. We want it to be a static body

12:05

child mesh. Create. And now this has

12:09

collision just like our other ones. We

12:12

also need to change the position because

12:13

we save the transforms when we export.

12:16

So our position for this is just going

12:18

to be just where the wall is. So

12:20

position Y 2, Z2.

12:24

There we go. We also want it to look

12:26

like our

12:28

other walls and all that. So with our

12:31

wall door selected, scroll down to

12:33

surface material override or scroll up.

12:36

There it is. right there. Go into where

12:40

our materials are and our wallpaper and

12:43

our wallpaper color. Drag and drop. And

12:48

then we also need to set in the

12:49

resource. Scroll down to roughness

12:52

wallpaper rough.

12:56

And then in our normal map, select that

12:59

on wallpaper normal.

13:02

We also don't want to forget our UV UV

13:06

one. And then the trip planer on. And

13:11

we're set the scale of the trip planer

13:12

to 0.5.

13:15

Perfect. Now it matches exactly our

13:18

wall. So if our wall shows up, you can't

13:21

even tell the difference.

13:23

Great. Now minimize that. And we don't

13:26

need our door frame builder anymore.

13:27

Could delete that. Delete door frame

13:30

builder. We have our wall door. We'll

13:32

turn our ceilings and the walls back on.

13:35

Now they're all in there. Position

13:36

correctly. Save the scene. Now we need

13:39

to export scene.

13:42

Export as mesh library.

13:45

And in our resources, we're just going

13:47

to overwrite this mesh pallet here.

13:49

Apply mesh instance transforms. If you

13:52

don't do that, they won't be in the

13:54

right spots. Save.

13:57

Overwrite.

13:59

Perfect. Now back in our world. Now,

14:01

sometimes GDAU needs a little help

14:04

finding

14:06

new meshes we add to our mesh pallets.

14:09

We go to our walls here. It looks like

14:12

it found it just fine. Perfect. If it

14:15

doesn't, yours doesn't come up. You can

14:18

just delete this mesh pallet,

14:21

clear it from your mesh library,

14:25

uh, restart the project, and then

14:28

do the same export as, and then put it

14:33

back into the grid map in the world.

14:36

Your positions will be saved

14:39

um, after you drag and drop your mesh

14:42

pallet back in your mesh library, but

14:44

then your new mesh will show up. At

14:46

least that happened to me a couple

14:47

times. Hopefully it doesn't for you and

14:49

it works just like it did right now.

14:51

Let's build a door. But we can't just

14:53

rotate the mesh or we'll spin around its

14:56

center. We need a hinge just like a

14:59

normal door. Now let's make a new scene.

15:01

So scene new scene. Then make a root

15:05

node 3D scene. Going to change this node

15:08

3D name to door. And then we're going to

15:11

add a child node of node 3D.

15:15

create. And we're going to change this

15:18

node 3D name to hinge. Now, the hinge is

15:22

going to need to be where the hinge

15:24

should be on the edge of the door. So,

15:26

we're going to take this transform of

15:29

this hinge and divide it by half or at

15:33

least. Yeah. So, our door is going to be

15:35

1.25. So, we want our hinge to be minus

15:39

0.625, 625,

15:43

which is half of 125.

15:47

And then after we have that set proper,

15:49

we could add a child node to our hinge

15:52

static body 3D.

15:55

Then we're going to add a mesh instance

15:57

3D as a child node to our static body

16:00

3D. Mesh instance 3D. The mesh we're

16:04

going to use is a in the inspector,

16:07

we're going to use a box right here.

16:11

Our box mesh, we click on the resource

16:14

here. The size of our box mesh is going

16:16

to be 1.25,

16:18

width or height 2.5, width of 0.1.

16:23

So it fits in our door frame of 0.2.

16:27

Then we need to add collision or static

16:30

body 3D. We're going to right click, add

16:32

child node, collision

16:35

shape 3D.

16:38

Our collision shape is going to be a box

16:40

and it's going to be the same size as

16:42

our door. So you select the box shape 3D

16:45

after we select it in the shape and the

16:46

collision shape 3D. Change the size to

16:49

just the same size as the door. 1.25,

16:53

2.5, 0.1.

16:57

There you go. that matches the door

16:59

perfectly. We also, if you look at our

17:02

hinge,

17:05

you'll see that it is in the center of

17:06

the door. So, we need to change our

17:09

static body 3D, the root. And then we're

17:12

going to go to our transform.

17:15

And what we're going to do here is

17:16

change the X to the opposite of the

17:19

hinge. So, instead of minus06.25,

17:24

it's going to be just positive 0.625.

17:28

And then if you click on the hinge, you

17:29

can see it's right on the edge of the

17:30

door. So we have our door here in the

17:33

middle and our hinge on the edge. So

17:35

this hinge will be able to swing this

17:37

door back and forth.

17:40

Well, whichever direction you want it to

17:42

swing. Usually doors only swing one way.

17:46

Ours will swing out. Now you've reached

17:48

a checkpoint. We have the door

17:50

hierarchy. Now we need to get the door

17:52

to turn. How do we do that? Should we

17:55

use an animation player? Well, we could,

17:58

but there's a way easier way to do it. A

18:01

thing called twins. Now, twins are

18:03

perfect for simple movements like this.

18:05

They're lightweight and easy to control

18:07

through code. So, what we're going to do

18:09

here, we'll attach a script to our door.

18:13

Attach script.

18:16

No, we're not going to put our root

18:17

folder. We're going to put it in our

18:19

scripts folder. It can be called door.

18:21

That's fine.

18:24

and then create.

18:26

And I'll make this bigger. Then we can

18:28

delete our boiler plate code here. And

18:32

we need to have access to the hinge. I'm

18:35

going to make this smaller again. And

18:38

then take this hinge. I'm going to drag

18:41

and drop it with control held down. Now

18:44

I have my hinge. Make this bigger for

18:46

you. Now we need to check have a

18:49

inscript variable and ask if this door

18:53

is open. Well, it's not going to be. So

18:56

we'll set it to false first.

18:58

Now we need the function that we wrote

19:01

in our player script. So we know that

19:03

this is interactable. So our function

19:05

called interact because that's what

19:07

we're looking for from the player

19:09

script.

19:10

Enter down. And now we need access to

19:13

the tween. So, we'll store that tween in

19:16

a tween variable. And now we can use a

19:20

function called create tween. Now that

19:23

we have a tween that we've created,

19:26

well, we're going to check if that open

19:28

is true. So, if it is open, well, we

19:32

want to close it first of all. So, close

19:35

the door. So, we take the tween we got

19:38

and then we're going to change the tween

19:40

property

19:42

property. And the property we're going

19:44

to change is a property on the hinge. So

19:48

we're going to take that hinge and then

19:49

we're going to rotate it. So we want to

19:52

change the property of rotation.

19:54

So we look up rotation. We don't want

19:57

the whole rotation. We just want

19:58

rotation on the Y. We don't want to do

20:01

the X or the Z. We just want rotation on

20:04

the Y. So that way we can just swing the

20:06

door open and closed.

20:10

And then we want to say where we want to

20:12

go, which is the zero point zero. So we

20:15

don't want to be rotated at all. So go

20:16

back to its default position. And then

20:19

we want to say how long we want to take

20:21

to get there. But if it is not open,

20:24

well, we want to open it, right? So open

20:27

it. Open the door. And these are 90°. So

20:31

that helps. 90° angles. So how do we do

20:35

that? Well, we just get the tween that

20:36

we just made and the tween property.

20:38

Tween property.

20:40

And then we need the hinge again. And

20:43

we're going to rotate again along the Y

20:45

rotation Y.

20:48

And then we need to change the the

20:51

degrees of the door by 90. So how do we

20:54

do that? We take degrees to rad. Now if

20:58

you look into this, you can

20:59

control-click and look at the degrees to

21:02

rad. converts an angle expressed in

21:04

degrees to radians. Now, what are

21:07

radians? Radians are this default unit

21:10

of measurement for rotation in scripts

21:13

and code and like internal calculations

21:17

in game engines and other engines too.

21:20

Measurements for angular stuff. So,

21:22

without getting too far into it, anytime

21:24

you use rotation on a node or node 2D or

21:28

3D, you're using radians. So like 360°

21:32

is what they say two pi radians a full

21:36

circle. 180 degrees is a pi radian half

21:39

circle. 90 is pi / two. So it's a

21:43

quarter circle which is what we're using

21:45

the 90. So back in our door script here.

21:49

Now that we have our degree to radian

21:51

what we're going to use is the 90. So we

21:54

want to go 90 degrees. We just put in

21:56

90. Pretty straightforward. And then we

21:59

want to say how long to take to get

22:02

there to 0.5

22:04

just like we did up here.

22:08

And now we change the door. Well, we

22:11

need to set the is open to whatever it

22:14

is. So is open is equal to not is open.

22:20

So basically what that's going to do is

22:22

change it to whatever the opposite is.

22:25

So is open will become either open or

22:27

not open. Now for the items. Since our

22:30

player script just looks for the

22:31

interact function, we can make anything

22:33

interactable without changing any player

22:35

code. A generic cube isn't scary though,

22:38

so let's make this look like a real VHS

22:40

tape. We'll use realistic dimensions and

22:43

add a simple label trick, so we don't

22:45

need any external 3D software. All

22:47

right. First of all, let's save our door

22:50

script and our door scene in our scenes

22:53

folder. Save. All right. Like that. Go

22:57

down. We need a new scene. We new scene.

23:02

Scene. New scene. It's going to be a

23:03

other node scene. The scene we're going

23:05

to use is a static body

23:08

3D. Right there.

23:12

We'll go back to our 3D section so we

23:14

see what it looks like. Then we use a

23:16

right click add child node of it's going

23:19

to be a mesh instance 3D. So right here

23:24

and rename this to body.

23:27

I'll rename this static body 3D to tape.

23:30

That's what we're making. And our body

23:33

here, we're going to change the mesh to

23:35

a box mesh here. In the resource section

23:41

size, well the size I looked up for tape

23:45

is going to be 0.19,

23:48

03, and 0.1.

23:51

There we go. We zoom in. Now we got a

23:54

shape of a tape.

23:56

Now we scroll down to surface material

23:59

override.

24:01

We're going to click into the empty

24:02

section. Create a new standard material

24:04

3D. And then we're going to click on

24:07

this resource here. And then we're going

24:09

to change the albido. We're going to

24:12

change it to a dark gray. Now you click

24:14

on the color and the hex symbol here for

24:18

dark gray. 1 A 1 A

24:22

1 A.

24:24

There we go. And then we want to make it

24:26

not shiny, too shiny. So we'll change

24:29

the roughness a little bit to to point8.

24:33

Just like that. An old plastic look. And

24:38

we need a label of sorts. So right click

24:40

on the body and add child node. Another

24:43

mesh instance 3D. We're going to rename

24:46

this to label.

24:49

All right. Now, this is going to be

24:50

another box mesh here. Box mesh. And

24:53

then click on the resource area and then

24:55

change the size of this so it's slightly

24:57

wider and shorter but taller so it'll

25:00

poke out of the top of the tape. So for

25:04

this dimensions.14

25:06

for the X, then 031

25:10

for the Y, and then 06.

25:15

There we go.

25:16

Oh, you know, that's a little too big.

25:18

Let's make that a little more

25:20

rectangular. So, we're zero. Divide this

25:23

in half. 0.07.

25:25

And then the Y, let's go to 0.02.

25:29

Oh, we need to bring that up a little

25:31

bit. So, 0.04.

25:35

Let's pull this up a little bit. There

25:37

we go. So, on the Z, we'll do 0.04.

25:41

There we go. Now, we're Oh, slow down.

25:46

If you hold right click and use the

25:47

mouse wheel, you can change your zoom in

25:50

speed. There we go. Now we're slightly

25:53

poking through just like that. Just on

25:56

the front. Perfect. But all black on the

25:59

back. Now we have the label.

26:03

If you get real creative, we can do the

26:04

reels on the side, but we'll keep this

26:06

simple for now. You can even import a

26:10

actual 3D tape, but we'll we're going to

26:13

do this way for now. The last thing we

26:15

need is a collision shape so we have

26:17

something to interact with. So on the

26:19

tape, right click, add child node,

26:21

collision shape 3D. And this is going to

26:24

be a box mesh in the shape. And we

26:27

change the box shape 3D to the same size

26:29

as the tape, which if you remember was

26:34

0.19 03 01. So collision a shape we can

26:40

do 019.19

26:44

03 and then 0.1 there we go now size of

26:48

this tape go and save that or save this

26:51

scene as tape

26:54

and now we need the interact function so

26:56

all we need to do for that is click on

26:58

the tape attach new script not our

27:02

scenes folder and put it in our

27:05

scripts folder tape GD is fine

27:08

create. Let's get rid of this

27:10

boilerplate code. Make this bigger for

27:13

you. And then we just need that interact

27:16

function. So function interact.

27:19

For now, we're just going to make it say

27:21

something in the console because you

27:22

don't have an inventory system.

27:25

Say picked up tape. That's something to

27:27

do later in a polish section or

27:30

something you do on your own. Or if

27:33

you're interested, you can let me know

27:34

and we can expand on this tutorial

27:36

later. And then you can also just play a

27:38

sound here. Play a sound here later.

27:41

Just like we do with flashlight if you

27:42

want to play a sound when you turn it on

27:43

and off. And for now, we're just going

27:46

to delete it. And after we say the print

27:48

statement, say, "Hey, we did the thing.

27:52

Delete the tape.

27:54

Now, let's put it in the maze." So, I'm

27:56

going to make that smaller. Go back to

27:59

my world scene 3D. All right. Take my

28:04

level down. Then I'm going to take my

28:07

scenes. I'm gonna grab my tape.

28:11

Put in my world scene. Find my tape.

28:14

Where'd it go?

28:16

There it is.

28:21

Speed this up. I'll just put my tape

28:23

over here.

28:25

Just put over here in the corner or

28:26

something.

28:28

There we go. Save the scene and run the

28:31

current scene.

28:34

All right. I'm g walk over to my tape.

28:37

I should be able to click on it and it

28:39

disappears. If I look at my console

28:42

here, I picked up the tape. Perfect.

28:46

Also test the door. If you remember the

28:50

room I put over here, if I go to the

28:54

level again, our grid map walls, I do

28:58

select this door. Then I'm going to use

29:01

the paint here.

29:04

I'm gonna take this spot here. I got

29:06

rotate with S. Wait. Oh, yeah. There it

29:10

is. Rotate with S. Put it there. Oh,

29:13

deleted that door there. So, I have one

29:16

wall per

29:18

section. That's fine. We'll leave that

29:20

for now. But I also need my door. So, to

29:25

get the door scene,

29:27

I'm going put that in my world here. I

29:30

find my door

29:32

here.

29:34

I'm going to turn on this snapping here

29:38

so that way it snaps along the grid

29:41

line. Also going to rotate it

29:45

hole

29:46

here.

29:48

Pull it up so it matches.

29:53

I'll turn off the grid snap there.

29:57

Put this back.

30:00

Center that in the hole there.

30:04

There.

30:06

I think there's a way to get the grid

30:07

snap to work better. Oh, there we go. I

30:10

think that works.

30:13

Is that blocking?

30:16

I'll turn off the grid snap.

30:19

I think that's blocking. Perfect.

30:22

There we go. If I click out of there.

30:26

I think that's blocking the doorway just

30:28

fine.

30:30

I'll put my player into this room. Now I

30:34

go get my player past all these lights

30:37

here. Player.

30:40

Let's bring my player over here.

30:43

I'll turn the player to be looking at

30:45

the door when the game starts.

30:48

There we go. Now we start in this room.

30:51

Going to save. Let's try this scene out.

30:54

Run current scene.

30:57

Now we're in this room.

30:59

Go up to the door. Click on the door

31:04

and nothing happens. Well, that's not

31:05

supposed to happen. Let's escape out of

31:08

there. Let's go back to our door scene

31:13

and

31:16

oh,

31:18

take this script off of the door here.

31:22

This is not going to detect collisions.

31:24

The static body 3D is going to detect

31:26

collisions. Well, that was silly. So, we

31:28

can rightclick, detach script, static

31:32

body 3D, come back down in our file

31:35

system, scroll down to our scripts,

31:39

find the door script. I'll drag the door

31:42

script onto the static body 3D.

31:45

And since we changed the hierarchy of

31:47

the script, we need to go back into our

31:49

script and scroll back up to this hinge

31:52

node. Instead of money symbol hinge, we

31:56

need to do get parent. Now since our

31:59

hinge is the parent of our static body.

32:02

Now we can get parent which is our

32:04

hinge. I go and save that. Go back to

32:08

our world scene.

32:10

Go to 3D. Give it another test.

32:15

All right. Now when you walk up to it

32:16

should open right up. Perfect.

32:20

We go to where our tape was, which I

32:22

think is over here.

32:25

Get lost in our own maze.

32:29

And yep, there it is. The corner. Grab

32:32

that. We are good.

32:36

It works. We have a universal

32:37

interaction system. You can use this for

32:40

light switches, notes, hiding spots,

32:42

anything. Now, we have movement,

32:44

atmosphere, and interaction. We're

32:46

technically playing a game. And if

32:48

you're following along, take a

32:49

screenshot of your maze and tag me on

32:51

Blue Sky. I want to see your level

32:53

layouts. But we are alone. Or are we? In

32:57

the next video, we're going to add the

32:59

monster. We'll program a simple AI that

33:01

stalks you through the grid map. Now, if

33:04

you found this helpful at all or fun,

33:06

leave a comment on what your GDO game

33:08

dev goals are. Please like, subscribe,

33:10

and hit that notification bell. It

33:12

really helps out the channel. And thank

33:14

you to all our current and past Patreon

33:16

and coffee members. Your generous

33:17

support keeps the channel moving. Now,

33:20

if you want early access to tutorials,

33:21

source code, or suggesting future

33:23

tutorials, please consider becoming a

33:25

member yourself. The links are in the

33:28

description. I'm Spaghetti Syntax, and

33:30

remember, always stay curious, and I'll

33:33

see you at the next checkpoint.

Interactive Summary

The video demonstrates building a universal interaction system for a first-person game in GDAU. It covers implementing a Raycast from the player's camera to detect objects and adding an "aim dot" reticule to the UI. The tutorial explains how to set up an "interact" action in the input map and write a flexible `interact` function using "duck typing," allowing various objects like doors and items to respond to player input without specific type checks. It details the process of baking custom doorframe tiles using CSG subtraction, building a functional door with a hinge, and animating its movement with GDAU's tweening engine, also clarifying the use of radians for rotation. Finally, it shows how to make a simple VHS tape item interactable, demonstrating the system's versatility before teasing the next video on adding a monster AI.

Suggested questions

6 ready-made prompts