Can you try
# ------------this all can't work in Aim Hero(unity)
pos = pyautogui.position()
pydirectinput.moveTo(900, 600) # estimated center position of screen
time.sleep(1.5) #'cause this code working slow
pydirectinput.click()
pydirectinput.click()
pydirectinput.click()
# -------------
instead of
# ------------this all can't work in Aim Hero(unity)
pos = pyautogui.position()
pydirectinput.moveTo(pos.x + 100, pos.y) # can't work in borderlands 2
# pos = pyautogui.position()
pydirectinput.moveTo(pos.x + 200, pos.y) # can work in borderlands 2
time.sleep(0.5)
pydirectinput.click()
# -------------
EDIT
Okay I found the problem! It's not about Python, it's about Unity. Let me show you a video from my computer .
As far as I understand, if you want to use the pydirectinput.moveTo() method in Unity game, you should not lock your cursor. Be careful about your cursor state and use CursorLockMode.None instead of CursorLockMode.Locked. But it wont be effective for real game :( And I don't know any alternative for now
Can you try
# ------------this all can't work in Aim Hero(unity)
pos = pyautogui.position()
pydirectinput.moveTo(900, 600) # estimated center position of screen
time.sleep(1.5) #'cause this code working slow
pydirectinput.click()
pydirectinput.click()
pydirectinput.click()
# -------------
instead of
# ------------this all can't work in Aim Hero(unity)
pos = pyautogui.position()
pydirectinput.moveTo(pos.x + 100, pos.y) # can't work in borderlands 2
# pos = pyautogui.position()
pydirectinput.moveTo(pos.x + 200, pos.y) # can work in borderlands 2
time.sleep(0.5)
pydirectinput.click()
# -------------
Can you try
# ------------this all can't work in Aim Hero(unity)
pos = pyautogui.position()
pydirectinput.moveTo(900, 600) # estimated center position of screen
time.sleep(1.5) #'cause this code working slow
pydirectinput.click()
pydirectinput.click()
pydirectinput.click()
# -------------
instead of
# ------------this all can't work in Aim Hero(unity)
pos = pyautogui.position()
pydirectinput.moveTo(pos.x + 100, pos.y) # can't work in borderlands 2
# pos = pyautogui.position()
pydirectinput.moveTo(pos.x + 200, pos.y) # can work in borderlands 2
time.sleep(0.5)
pydirectinput.click()
# -------------
EDIT
Okay I found the problem! It's not about Python, it's about Unity. Let me show you a video from my computer .
As far as I understand, if you want to use the pydirectinput.moveTo() method in Unity game, you should not lock your cursor. Be careful about your cursor state and use CursorLockMode.None instead of CursorLockMode.Locked. But it wont be effective for real game :( And I don't know any alternative for now
Can you try
# ------------this all can't work in Aim Hero(unity)
pos = pyautogui.position()
pydirectinput.moveTo(900, 600) # estimated center position of screen
time.sleep(1.5) #'cause this code working slow
pydirectinput.click()
pydirectinput.click()
pydirectinput.click()
# -------------
instead of
# ------------this all can't work in Aim Hero(unity)
pos = pyautogui.position()
pydirectinput.moveTo(pos.x + 100, pos.y) # can't work in borderlands 2
# pos = pyautogui.position()
pydirectinput.moveTo(pos.x + 200, pos.y) # can work in borderlands 2
time.sleep(0.5)
pydirectinput.click()
# -------------