For some reason, my bullets seem to go incredible off when shooting through these doors, or when the tip of your gun is inside a wall. The bullets should ignore your teams door, which it does, but I get really weird results on the raycast, where it goes backwards and all that?
You can see bullets being shot backwards, even tho I am aiming in the same spot every single time. Even when my gun isn’t in the door, the rays act weirdly, and don’t actually land where they should.
local SPEED = Config:GetAttribute("Speed")
local GRAVITY = Config:GetAttribute("Gravity")
CastParams.FilterDescendantsInstances = {
Camera,
player.Character,
Splatter,
Bullets,
workspace.Map:GetChildren()[1].TeamDoors[Player.Team.Name]
}
if GameSettings:GetAttribute("Teams") then -- Team based gamemode
CastParams.CollisionGroup = player.Team.Name == "Blue" and "BluePaint" or "RedPaint"
end
-- Set up cast behavior
local CastBehavior = FastCast.newBehavior()
CastBehavior.RaycastParams = CastParams
CastBehavior.Acceleration = Vector3.new(0, -GRAVITY, 0)
CastBehavior.CosmeticBulletContainer = Bullets
CastBehavior.CosmeticBulletProvider = BulletCache
-- Projectile math
local Origin = firePoint
local Direction = (mousePosition - Origin).Unit
local ActiveCast = Caster:Fire(Origin, Direction, SPEED, CastBehavior) -- Fire shot
Note, I am using FastCast. I would post this problem in that thread, however I’ve posted several problems there already and gotten no response, so figured here would be better to ask
It looks like your mouse is hitting the invisible door. The offset between your mouse position and the gun barrel causes the discrepancy. Do you need an invisible door? You might need to use a camera ray that ignores transparent parts to find the actual mouse position. But so long as you are using mouse position in your equation, it will always get wonky in close proximity to walls and players and stuff.