FastCast just misses in first person?

  1. Fastcast is broken when it’s in first person.
  • I have recently used Fastcast because Roblox raycasting is kind of expensive these days…
  1. Fastcast is paired PartCache
    Understandable, no further questions explained
  2. Problem:

Apparently this is the source of the problem:

local function fire(player, Origin, Direction, Velocity, Drop)
	rayParams.FilterDescendantsInstances = {player.Character}
	local origin = Origin
	local directionalCF = CFrame.new(Vector3.new(), Direction)
	local direction = (directionalCF * CFrame.fromOrientation(0,0, rng:NextNumber(0, tau)) * CFrame.fromOrientation(math.rad(rng:NextNumber(bullet_property.bullet_min_spread, bullet_property.bullet_max_spread)), 0, 0)).LookVector
	local mousedir = (Direction - Origin).Unit <-- This part is the problem
	castBehavior.Acceleration = Vector3.new(Wind.X/2, Wind.Y/2 - 0.367 * Gravity - Drop * Gravity, Wind.Z)
	
	caster:Fire(origin, direction, Velocity, castBehavior)
end

Since i think it’s either the Origin (aka gun muzzle worldPosition) or the Direction (aka mouse.hit.p). Any helps would be appreciated!

Also this is the bullet’s property btw

local bullet_property = {
	bullet_gravity = Vector3.new(0, -workspace.Gravity, 0);
	bullet_min_spread = 1;
	bullet_max_spread = 5;
	bullet_speed = 1000;
	bullet_maxDist = 2500;
	canPierce = true;
};

I won’t ask and wait for a response so i’ll just slap a possible solution. If you’re using a viewmodel make sure to add it to your ignore list otherwise the tip of the gun will catch your mouse and then it will calculate the direction from your origin to the tip of the gun making it miss.

I’ve had a similar issue before which I solved by making my own Mouse Hit module with regular roblox raycasting with a set blacklist which contains the character and the viewmodel object.

huh havent thought of it. I’ll try

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