So I’ve been trying to change the orientation of an object being fired using the fastcast module but it wont work.
https://gyazo.com/1a8bcb5e319bfc584221c29ebc9606ec
Im trying to make it face this way
How do i go about fixing this?
So I’ve been trying to change the orientation of an object being fired using the fastcast module but it wont work.
https://gyazo.com/1a8bcb5e319bfc584221c29ebc9606ec
Im trying to make it face this way
How do i go about fixing this?
Assuming this is a MeshPart, you just need to change the Orientation of the part you’re referencing while FastCast-ing. I can’t tell you the orientation but trial and error ought to get you your problem solved. Parent your MeshPart to Workspace, rotate at 90 degrees increments, parent to original place and try throwing.
This isn’t a fastcast issue, rather a CFrame related issue. To fit this, I’d recommend using the lookat constructor on CFrame (deprecated, but still works) to look at the end position, along with using the fromMatrix constructor to switch the LookVector and UpVector.
Here’s an example:
...
Projectile.CFrame = CFrame.new(projectile.Positon, endPositon)
Projectile.CFrame = CFrame.fromMatrix(Projectile.Position, Projectile.CFrame.RightVector, Projectile.CFrame.LookVector, Projectile.CFrame.UpVector)
If you don’t feel comfortable using deprecated methods, then you can use this:
function lookAt(target, eye)
local forwardVector = (eye - target).Unit
local upVector = Vector3.new(0, 1, 0)
-- You have to remember the right hand rule or google search to get this right
local rightVector = forwardVector:Cross(upVector)
local upVector2 = rightVector:Cross(forwardVector)
return CFrame.fromMatrix(eye, rightVector, upVector2)
end
sry for reviving this old thread but i have this same problem (also i cant change orientation, for some reason the CosmeticBullet (projectile) will always be 0, 0, 0
there is no “endPosition” and idk how to use the lookAt function (eye and target are nil so i get errors when i wanna do eye - target).
EDIT: I think is impossible to get the target or EndPosition because its impossible to know where the projectile will end up (it doesn’t use mouse.Hit, it has gravity and stuff like that), if I set mouse.Hit as target/EndPosition it would probably start to fall down (because of gravity in FastCast) and still looking upwards (or wherever the mouse.Hit is).
ty!
local direction = (startPos-endPos).Unit -- You can use (startPos-TargetPos).Unit
caster.LengthChanged:Connect(function(cast,lastpoint,direction,length)
local blength = weapon.Size.X/2 -- Example: if your weapon size is (9,1,1) X Y Z, X is larger than Y and Z then bLength is (weapon.Size.X/2)
local offset = CFrame.new(0,0,-(length-blenght))
weapon.CFrame = CFrame.lookAt(lastpoint,lastpoint+direction):ToWorldSpace(offset)
end
caster:Fire(origin,direction,velocity,behaviour) -- Origin or StartPos (Vector3)
-- Vector3
-- Number(Speed)
-- Caster.newbehaviour (behaviour.params,etc...)
It’s perfect orientation!
Srry to bring dis up but im using PartCache for a cosmetic bullet provider, and it wont work with it. any idea why