Velocity into Cframe?

How do I turn a velcoity into a cframe? I want something like: vector3 * speed = cframe

1 Like

What exactly do you want to do with velocity? Do you want to move a part by the velocity?

The CFrame constructor accepts a single Vector3 value which becomes the position element and the rotation matrix is left empty.

--example
local velocity = Vector3.new(1, 2, 3)
local cf = CFrame.new(velocity)

If you want to move a part by a so-called velocity, you can simply translate the CFrame by the velocity:

part.CFrame += velocity --velocity being a Vector3
3 Likes

oh sorry I mean that if the velocity was straight up then the part would rotate so it facing straight up

1 Like

So you want the part to look in the direction that its going?
If so then use CFrame.LookAt()

Part.CFrame = CFrame.LookAt(Part.Position, Part.Position + Part.Velocity)

Correct me if I’m wrong.

4 Likes

That seems right, but Im getting an error…
image

image

The function is suppose to return a CFrame because I am setting a cframe to the function

1 Like

image

1 Like

May I see the rest of the code?

2 Likes


The bottom line there is the one where I get the error

1 Like

What values do “position” and “velocity” represent? A general example would be useful, i.e; if they are numbers, Vector3s etc.

The red dot there is a breaking point, it stops the script at that point
grafik

1 Like

its CFrame.lookAt not CFrame.LookAt

2 Likes

yes I did that for testing as you can see its at a return line

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.