FastCast Offset problem

There is a slight issue with the bullet offset; to explain whenever i look at different coordinates the offset will change, the offset is exaggerated to further illustrate the issue.

I have made the offset so that it would fire to the left but changing camera angles seems to displace it

local Angle = Vector3.new(1,0,0)                     -- exaggerate bullet offet
local Pos = charWeapon.Shoot.Position          -- weapon shootpart
local direction = (mouseHit - Pos).Unit + Angle
CasterModule.CreateCast(Pos,direction ,700,mouseHit)

You must use CFrames in order to create an offset like that. Simply * on the Offset CFrame, Also move the post to Scripting support.

1 Like

What happens when you remove the angle?

there will be no offset and the ray will just fire straight

You aren’t exactly adding to the origin, you are adding to the direction I believe. Try adding to Pos.

adding it to the pos will just deviate it from the shoot position;

This is because you are adding it in object space when it should be in world space.

1 Like

I believe that could be the right awnser but the way i set up my recoil is with a large table with random vector3’s. So while the ShootPart will be in world position the Recoil pattern will be in Object space

I wouldn’t recommend that for recoil. There’s a Random function dedicated for producing random unit vectors, I recommend you look into that.

Yes i can use Math.RandomSeed which is ultimately the same thing
Im using seeded Recoil which is independent from server - Client which is what most E-Sports Fps use instead of generating random offsets in the spot.

This was ultimately the solution i had to use CFrame.fromOrientation and it worked just fine
thanks you guys for helping

		local Pos =  self.Weapon.Shoot.Position  
		local directionUnit = (self.mouseHit - Pos).Unit 
		local directionCF = CFrame.new(Vector3.new(0,0,0), directionUnit)
		
		local spreadAngle = CFrame.fromOrientation(math.rad(10), 0, 0)
		local direction = (directionCF * spreadAngle).LookVector

Hey unrelated question, but how did you get rid of the offset that fastcast has when the velocity is high?

You simply have to wait a frame before moving the bullet.

can you tell me how and where? I tried putting it somewhere in the fastcast module but no luck

I’m not sure where it is in FastCast. I’ve only applied this method to my own systems, so I’d recommend you create a separate topic for it so people who do know can answer the question.