"Printing" Rays - Module

Hey again!

Example Result

image

Motivation and Intro

I was working in my last game, and everytime that i need to handle with RayCast ive got a little confused.
So, to help me to exactly understand what happen with my raycasts, i work out on a simple module function that can show me the behavior of my ray.
Obviously, im using the old datatype called Ray to do this, but its easily to change the module if u wanna.

How To Use

Import the module:

local PrintRay = require(--[[Put the path to archive here]]--)

Then just call it passing a ray and a number that will be used to split the ray into this segments.

local NewRay = Ray.new(Vector3.new(0,0,0), Vector3.new(5,5,5))
PrintRay(NewRay, 15)

Done!

I really hope that can be usefull to u all.

Cya!
PrintRay.lua (1.8 KB)

3 Likes

Hi there, can I know some applications of visualising a ray’s behaviour?

The Ray object is deprecated and today people mostly use workspace:Raycast instead; so this module won’t work for developers using the newer method. Other than that, it’s good I guess.

I put an example in the post. plz, read it :smiley:

The thing you said is practically “yeah I know I’m using a deprecated type, you can change the code yourself if you want something different”

The Ray class is not deprecated. Only the old raycasting API is (WorldRoot:FindPartOnRay et al). Methods like camera:ViewportPointToRay still return ray objects, but if you want to do raycasting with them you can still use the new API, you just make use of the Origin and Direction properties of the returned object. So this is fine.

3 Likes

First of all: At no point do I use something that has been deprecated. Ray is an Object, at no time do I use FindPartsOnRay().
You don’t understand the basics, and want to come talk nonsense about someone who is publishing something trying to help others.

1 Like

Finally someone that reads and understand the code before to comment. Thank you, mate!

And? Any problem with that? No.

1 Like

I beg your pardon? I don’t understand the basics? Please take a look at my other posts before assuming things like that.

It’s the attitude, not the code itself that bothers me.

Your reply was obsolete and didn’t help anyone. You could’ve just refrained from writing it altogether. I don’t use the same method - still - I appreciate him trying to help others.

1 Like

You’re the kind of person the community doesn’t need.

3 Likes