Raycast and Expressions

Hello, I would like to learn how to use raycast but I can’t find a tutorial anywhere and I don’t know if it’s the kind of thing where I can teach myself. Where should I start? I would also like to learn expressions but I don’t really understand how I could use them in a sprites behavior.

Raycasts are pretty simple, they detect stuff in a line, you can think of them as a laser that detects if something is in front of it. Here’s a tip, if you click on the raycast behavior you can see where it will detect if you look at the object.

Expressions are just calculators, they do math. they’re great for making custom physics or smooth motions. They can be really helpful.

If you need more info you can always go to the behavior handbook.

I’m sure other people have tons of more information on the topic but here’s an introduction.


Yeah, what glowbug said, my explanation would’ve been worse

1 Like

Alright, thanks for the information! I keep seeing AI’s with raycast and I knew what it meant I just had no idea how to use them. I’ll try to learn as much as I can with the expressions and how and where to use them.

1 Like

Raycast and Expressions Test

Did I do everything correctly? Is there any unnecessary code?

1 Like

Also the title’s a link ^

1 Like

Can you explain what the game is and what you were trying to do?

I was trying to test raycast and expressions.

I wasn’t making a game

How, like as in player movement or something else, what were you trying to make with the raycasts.

Make the other block teleport away from the player every time it was close to the player.

1 Like

I see, yeah, it’s great! The code is simplistic and organized and works really well.

Alright, thanks! I guess raycast and proximity work a lot a like just raycast is for more advanced AI.

1 Like

As I said before they’re basically lasers, really helpful for more precise collisions and one sided proximity, great alternative for the basic proximity. Overall they’re just really handy.

Yep, thanks again for all the help! Can’t wait to find a way to use them in my multiplayer shooter!

1 Like

Cool, looking forward to hearing more about what you do!