[v1.5] Create Dynamic Crosshairs! (Updated!)

i believe it uses offset as it doesn’t re-position, This one’s an easy fix by changing the number of this one here (circled below) as it doesn’t calculate the mouse position, not sure why is there a minus here but that’s how i fix it for image crosshair and center dot.

I kind of fixed this, but whenever I use raycast there is a bit of an offset, probably because I am making an OTS gun system and there is camera offset. Any way to fix this?

The green part is where the ray landed, and the red part is where it should have.
image

Code for this:

function CasterModule.Cast(Origin, Direction, Module, Blacklist)
	RayParams.FilterDescendantsInstances = Blacklist
	
	local _, Dir = Gui:Raycast()
	CastBehavior.MaxDistance = Module.Range or 500
	Caster:Fire(Origin, Dir, Module.Velocity, CastBehavior)
	
	Gui:Recoil()
end

This is using fastcast, so I don’t need to multiply anything but it has the offset as shown in the picture.

As @pankii_kust says,

Now, this WILL work but I’d suggest updating the module for a complete fix (so you don’t have to trial and error)

Now for your raycasting, I wouldn’t suggest using it for third-person shooters. The reason why is the direction returned from the :Raycast function is the direction from the camera to the hit point, not the gun to the hit point, resulting in a weird offset. There is probably a workaround you can mess with but as of now, it will most likely not work without having a different spread mechanic.

I found a workaround, I just had to make a raycast from the camera to the direction times the distance and then use that as the position.

1 Like

What about the :Shove() going all the way though? Any fix for that?

Could you send some examples (videos, images) through a private message and we can discuss it there?

At the moment thew :Shove function is bugged and I haven’t had time to fix it. I’d suggest using :Set instead for the moment

After disabling & destroying the Dynamic Crosshair (DCH) object, I get these errors every frame. I’m trying to use a new DCH every time I equip a specific Tool & destroy/disable the DCH when I unequip the tool… Am I disabling it incorrectly?

image

Found a workaround for this.

Also the Centerdot doesnt seem to disappear when I set CenterDot.enabled = false.
It remains visible on my screen & in the last position it was in before I set CenterDot.enabled = false.

Thanks for reporting this, i’ll update this with a fix as soon as I can

1 Like

Could you make a video tutorial on how to use it ??

I also got this error:

image

Would you mind telling me how you solved it? I would greatly appreciate it.

Thanks,
Fizzitix

I check if the Dynamic Crosshair Exists, disable it instead of destroying it & disabling the crosshair screen gui when my weapon is unequipped

if DCH then
		DCH.CenterDot.enabled = false
		DCH:Disable()
		screenCross.Enabled = false
end
1 Like

I also get this error when I try to raycast from the module, just a heads up @Towphy (Line 280).

Yea, if a video would give people a better demonstration of how to use the module, I’d do it.

Could you send an example of your code?


Should be fixed, make sure to import the latest version of the module! Sorry for the inconvenience!

Thx cause I have being trying to work the module

Documentation is a little weird and confusing so my code might not be accurate, but this is what I’ve got:

Setup:

local crosshair = dynamicCrosshair.New(crosshairGui)

crosshair:Enable()

crosshair.EasingStyle = Enum.EasingStyle.Quad
crosshair.EasingDirection = Enum.EasingDirection.In
crosshair.Spreading.IncreasePerSecond = 30
crosshair.Spreading.Spread = weaponConfig.spread

Raycast:

local destination = dynamicCrosshair:Raycast()

Hope this can get solved soon!
Fizzitix

1 Like

Doesn’t look there is anything wrong, have you tried updating the module to the newest version? If that still doesn’t work can you send me a place file in private messages so I can check myself?

hi! i’m having a problem with the smooth set function, it’s slightly delayed, can you help me?

Yea can you send me a private message with your code and maybe some example of it being delayed?