Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I rotate a character torso to the face of a brick?

Basically, I'm trying to rotate a character torso to turn towards the face of another brick, making the player parallel to the part. What's the best way to do this?

2 answers

✓ Accepted answer

When creating a CFrame using

CFrame.new(pos, lookAt)

it accepts two arguments. The first (pos) is a Vector3 position which is the location of the CFrame. The second (lookAt), is a Vector3 position which, if included, will be the position which the CFrame is facing. Thus, you can use:

lookAt = workspace.LookAtMe.Position
Torso.CFrame = CFrame.new(Torso.Position, lookAt)

The Front face of Torso will now be facing LookAtMe.

EDIT: To make the player parallel to the part, it depends on where the player is relative to the part.

If the "giant, long wall" has its Front face facing towards the player, then:

lookAt = Torso.Position - workspace.LookAtMe.CFrame.lookVector
Torso.CFrame = CFrame.new(Torso.Position, lookAt)

Alternatively, if other faces are facing the player, a different lookAt would be required:

lookAt = Torso.Position + workspace.LookAtMe.CFrame.lookVector --Back facing player
lookAt = Torso.Position - workspace.LookAtMe.CFrame.rightVector --Right side facing player
lookAt = Torso.Position + workspace.LookAtMe.CFrame.rightVector --Left side facing player
lookAt = Torso.Position - workspace.LookAtMe.CFrame.upVector --Top facing player
lookAt = Torso.Position + workspace.LookAtMe.CFrame.upVector --Bottom facing player

7 comments

0

So, if I was trying to get the player to face a giant, long, wall, would it have the player face the center of the wall or face the wall relative to where I'm standing?

0

I'm trying to keep the character parallel to the object it's facing, no matter where it is.

0

This complicates things; in most cases either the part or the player will have to move in order to make the player both facing the part and be parallel to the part.

1

Or do you intend to only make the player parallel to the part?

0

I only intend to make the player parallel to the part.

0

I've updated the answer.

0

I would upvote this if I could. Thanks this helped me!

This discussion is preserved as it was. New answers, comments, and votes are closed.