How can I make look like the humanoid at the direction not where I raycasted?

Hello I want raycast but it should look in the direction where I raycasted.

Hello I need help. I will explain everythin in picture because then you can understand better.
Here what I want:

This is step 1:


Now if I raycast:

Fine! Everything what I needed but if I try to the other side like that this happend and thats not what I wanted:

My target is it: That the HumanoidRootPart should look at the direction where I raycasted and not with! CFrame.new(position, lookAt) because then this happen:


It should JUST LOOK AT THE DIRECTION NO MORE WHERE I RAYCASTED LIKE THAT!

If you want test it out then just do an Input then test it by urself.

Please just write the edit in the comment and if you need the game link pls write to me privat I will send to you and if you solved privat I will make you comment here solved.

3 Likes

Then I think you’re doing something wrong, because that should be the solution. But it shouldn’t matter anyways since the ray is created based on where you are already facing.

1 Like

No thats not what I want because it is buggy look

1 Like

CAN YOU SEE THIS?!

image

This?!

1 Like

It is not on the wall and the humanoid direction looks where it raycasted. it should look at the direction not where it raycasted

1 Like

How to make a Light Reflection Script - Roblox Studio - YouTube – This is a good video I think so

But actually I want a look direction. This video ist just a tipp

I am thinking about to convert this refflection math function into
image

But I dont know if that is working

use cframe.lookat with the hit part’s position

It seems like you want the Character to face in the direction of the surface normal.

You can access it like so:

local rayCast = workspace:Raycast(...)
local normalVector = rayCast.Normal

Of course, since the normal can point upwards and downwards, you want to avoid having your character tilting up and down. You can simply remove the Y component.

normalVector = Vector3.new(normalVector.X, 0, normalVector.Z)

You can then have the humanoid face the direction of the normal:

HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.Position, HumanoidRootPart.Position + normalVector)

So dou you mean I can use my current Raycast for Raycast.normal? Since when does raycast normal exist never heard.

I am a bit confused so how can it actually work with my script?

You can easy copy my script and just do an input and then use it for urself.

Yes, you can do RaycastResult.Normal to get the normal, the vector will be the surface normal of the object it hits, which is a direction pointing away from the wall depending on where the raycast hits it.

It doesnt work I dont know gives me different direction from the humanoid

:frowning:

Ohhh this happen in you script 100% I did like you said

Thaaanks hahaha really I love you hahaha