Calculate ray origin, direction and length on a sloped wall

So in this image we have a set:
Y = 5 (studs high)
n = 5 (studs away from origin in either X, or Z axis)
dir = -6 (On Y axis)

Here’s the sloped wall problem:

Now, since my set numbers would have to be calculated instead, since angles are a thing.
I was instructed by an anonymous smart guy to do this:

I read about CFraming and Vectors for about 5 hours, learned what Dot and Cross products are but .FromMatrix and using them to get Y, n and dir is out of my reach, I need some clearer instructions if anyone on the DevForum can help me out, please.

bump, I need major help wit hthis please

Could you clarify your question? I’m not sure what you’re asking for help with.

It’s all written up there and what the issue is, I’m not sure what I didn’t clarify.

I see zero questions and no reference to any issue. There seems to be some unknown variable in one of the screenshots, but I do not have enough information to figure out what this represents or what you’re trying to find.

When working with the baseplate (a flat surface), we can easily define the following:

  1. Y (the height vector): This is simply a vertical vector, such as Vector3.new(0, 5, 0), because the surface is flat and aligned with the world axes.
  2. n (the normal vector): This is the surface normal, which in the case of the baseplate points straight up and can be thought of as a combination of the origin position and the height vector.
  3. dir (the direction vector): This would typically represent a direction perpendicular to both the height and the normal vector, such as Vector3.new(0, -1, 0) for a flat baseplate.

However, things change when dealing with sloped walls or other angled surfaces.

  • On a sloped surface, the Y vector (height) is no longer perfectly vertical; it needs to be adjusted to align with the slope. For example, it might look more like Vector3.new(4, 6, 0) rather than Vector3.new(0, 10, 0).
  • To determine the proper angle and direction, you must calculate it relative to the surface’s normal vector (n), which you can obtain from a raycast hit.

In this scenario, the challenge is figuring out how to move the height (Y) based on the slope of the surface. The normal vector will guide the adjustment, but you’ll need to compute perpendicular vectors (dir) dynamically to define the final orientation.

are you trying to cast a ray from the surface of a rotated part? im also confused