How to add an Offset to LookVector?

Hello,
I need help with scripting a projectile but have it Miss. I have the code to actually hit the target but now I want it to a miss.


` windBV.Velocity = Vector3.new(tempAirType.Main.CFrame.LookVector+Vector3.new(0,0,offset)) * 60`

I’m sure the " +Vector3.new(0,0,offset)" is wrong but I don’t know how to add an offset to the LookVector. Thank you for your help!

You can get the LookVector, then add it by a small value of some sort then get the unit vector. Basically, you make the LookVector shifted in a direction then you make the length of the Vector 1 stud long:

LookVector = (LookVector + Vector3.new(offsetX, offsetY, offsetZ)).Unit

Plus or minus Vector3.new(0, 0, 0) would be fine. You could also multiply the LookVector by a scalar.

Something like 1.05 etc.

Ok something like this?

tempDisorder.Main.CFrame.LookVector = (tempDisorder.Main.CFrame.LookVector + Vector3.new(0, 0, offset)).Unit
		windBV.Velocity = tempDisorder.Main.CFrame.LookVector * 60

Ah nope, This didn’t work, How exactly would I get the LookVector and change it?

Yes, something like that. Although, I recommend offsetting in all 3 directions as all you’re doing right now is offsetting forwards.

I get the error "LookVector cannot be assigned to "

That’s because you’re assigning CFrame.LookVector to a Vector3.

Then what am I suppose to set it to? Whats the script?

I thought you were using a ray to detect collisions, are you using a part and scripting its trajectory? If so you can make it face towards the direction by doing:

Part.CFrame = CFrame.new(Part.Position, Part.Position + LookVector.Unit)

Then you can script how long the part travels by multiplying by a number (which is in studs) to the unit vector:

local landingPosition = Part.Position + LookVector.Unit * 500 -- Will travel 500 studs
2 Likes