Intro
Hey , Towphy here. I just finished a quick project of mine consisting of Dynamic Crosshairs! I couldn’t find many resources on how to create a crosshair online so I decided to give the internet this module!
This looks promising but i wanted to know if this can be used with pre-made Crosshair image without creating UI in the scripts
All i see in example was created by using scripts (I don’t like creating UI inside script as it’s time consuming when it comes with fixing position)
also
A great module, surely any scripter who’s been in the business for more than a year would be capable of doing something like this - though I’m certain it wouldn’t be as optimised, smooth and compact as this module. It’s time-saving to say the least, awesome job!
glad that it worked with the image but damn sad that i cannot use one single image and hopefully there will be, since i lov using this type of crosshair
Did a few little raycasting tests with a Sniper I made a while back!
Also, proof DyanmicCrosshair:Raycast() works correctly lol
If you are interested in the code, here ya go:
Click Here!
local RunService = game:GetService('RunService')
local UserInputService = game:GetService('UserInputService')
UserInputService.MouseIconEnabled = false
local UI = script.Parent
local DynamicCrosshair = require(script:WaitForChild('DynamicCrosshair')).New(UI)
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
DynamicCrosshair:Enable()
DynamicCrosshair:Max(120)
DynamicCrosshair:Min(60)
local function CreateBullet(ray, origin, direction)
local intersection = ray and ray.Position or origin + direction
local distance = (origin - intersection).Magnitude
local bullet_clone = Instance.new("Part")
bullet_clone.Material = Enum.Material.Neon
bullet_clone.Size = Vector3.new(0.1, 0.1, distance)
bullet_clone.CFrame = CFrame.new(origin, intersection)*CFrame.new(0, 0, -distance/2)
bullet_clone.Parent = game.Workspace.Bullets
bullet_clone.Anchored = true
bullet_clone.CanCollide = false
end
local function RenderStepped(dt)
DynamicCrosshair:Update(dt)
end
local function Click()
-- shove crosshair
DynamicCrosshair:Shove()
-- raycast
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = {Player.Character, workspace.Bullets, workspace.CurrentCamera}
local origin, direction = DynamicCrosshair:Raycast()
local ray = workspace:Raycast(workspace.CurrentCamera.CFrame.Position, direction*50000, params)
CreateBullet(ray, origin, direction)
end
RunService.RenderStepped:Connect(RenderStepped)
Mouse.Button1Down:Connect(Click)
This is a really neat module! Good stuff!
Will the module be receiving more updates in the future, it’ll be cool to maybe have an example place with the UI will be really nice. Overall good job!
Functions like Min(), Max(), etc have been replaced with DynamicCrosshair.Min = numberValue. DynamicCrosshair.Max = numberValue, etc to simplify the module!
[!] The function :SmoothSet() got a total rework [!]
You can now implement EasingStyles and EasingDirections inherited from Roblox’s TweenService when using SmoothSet()
SmoothSet() also got a new argument, which is UpdateMin.
The UpdateMin argument changes the crosshairs minimum spread meaning the decreasePerSecond spread won’t affect it after the SmoothSet is completed.
The UpdateMin argument will also always default to False
Alternatively, you can use DynamicCrosshair’s Lock() function which would have the same result that would look somewhat like this: