nihilitus93 0 Posted August 1, 2023 I'm making a script that mines and then walks to the back, deposits it and walks back. I've written the script so that I can start it anywhere and it will walk to the specified coordinates and start mining again. Here's My Problem: since I am using GameObjects.closest(ore name here) for example, if the script detects any object matching that name along the way to the coordinates, it will try to interact with that object instead. How can I check if my player is within a specific area BEFORE trying to interact with an object? basically walk,walk,walk -> am I in specified area? NO(keep walking to coords) YES(look for/interact with object)
camelCase 310 Posted August 2, 2023 sounds like you should use closest with a predicate GameObjects.closest(x -> x.getName().equals(your desired ore) && yourArea.contains(x)) this will look at all the objects, test that their name is that ore and they are in that area, is that test is true you get that object
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now