I made a lock on system for my JoJo game, everything is perfect, but the problem is that the unsummoned stands within the target are blocking my mouse, preventing from locking onto the target. Here’s what it looks like: https://gyazo.com/d28f3647fbb2a1a3c73904b94ab5f344
Is there any way to get around this? Or will I have to relocate every stand to be in a specific folder, which will take a REALLY long time to do, this includes recoding everything ;-;
As you can see from the GIF, it did not allow me to lock onto my target because my mouse was over the invisible stand, but as soon as I hovered over the little hand sticking out, it allowed me to.
Yeah, for this scenario don’t use the mouse object when we have the newer superseded version which requires more work to setup but is more customisable for your purpose. Essentially create your own custom Mouse object.
Here’s the steps.
Get Mouse Location on the screen through GetMouseLocation() to get the X,Y coordinates
Cast a ray from the camera using screen point to ray to a shoot a ray using the previously required x,y coordinates with a direction starting from the camera screen straight forwards (into the page).
Hold on, actually you can just use Ego Mooses UserInputService mouse object instead to save yourself a bit of work, perhaps check it out and see if it works as well?
I already tried his module before, but it doesn’t really apply to my problem and it didn’t solve the problem when I tried to use it, thanks for trying to help though.
I was using your other solution, but I don’t see how I can get the target to lock onto.
local UIS = game:GetService("UserInputService")
local mouse = UIS:GetMouseLocation()
local unitRay = Camera:ScreenPointToRay(mouse.X, mouse.Y)
local ray = Ray.new(unitRay.Origin, unitRay.Direction * 80)
Haha, looks like I just needed to dig a little further for help. Here’s the actual solution.
local mouseUnitRay = mouse.UnitRay
local ray = Ray.new(mouseUnitRay.Origin, mouseUnitRay.Direction * 1000)
local part, position = workspace:FindPartOnRayWithIgnoreList(ray, ignoreDescendantsTable)