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

A little help with LookVector?

I'm making a plane that drops a bomb onto the map, and I want the bomb to be facing the direction of the plane's "bombpart" which is the part attached to plane in which the bombs CFrame is set to. It is not positioning to this part anymore once I added LookVector. I know this is something that can be easily fixed, so please tell me how to use it properly.

local bomb = coroutine.wrap(function()
	for i = 1, bombnumber do
		local b = game.ServerStorage.bomb:Clone()
		b.Parent = game.Workspace
		b.CFrame=CFrame.new(script.Parent.bombpart.CFrame.LookVector) 
		b.Velocity = Vector3.new(0,0,speed)
		wait(0.2)
	end
end)

--Line 5 doesn't function properly.

1 comment

0

i dont know anything about lookvector, but it doesnt look like you identified the 2nd object that the plane is supposed to look at? ill go look back at "Understanding CFrames" because im kinda stuck myself...

1 answer

✓ Accepted answer

LookVector is just a unit vector, all values ranging from -1 to 1. If you were to try to set a value to the unit vector, it would be super close to (0,0,0). Instead, you should add the LookVector to the part's CFrame in order to get things working. If you want it a distance from said vector, multiply it by a scalar to expand. If you multiply the LookVector by 5, it will be 5 studs in front of the part. Multiplying by a negative would move it backwards.

script.Parent.bombpart.CFrame + script.Parent.bombpart.CFrame.LookVector

CFrame + Vector3 is still a CFrame, so you don't need the constructor. Cheers.

1 comment

0

Thanks for giving me a better explanation!

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