I'm using ursina to make a game, and I want to detect a left click so that I can shoot. So, here's my code :
def update(self):
if held_keys['t']:
print("it works !")
Whenever I press 't', it prints 'it works !', and if I hold it, as long as it's held, the message is printed. Great ! But now, if I try with 'left mouse down' for my key, it doesn't work anymore ! My code would then be :
def update(self):
if held_keys['left mouse down']:
print("it works !")
So, the problem here is clearly the 'left mouse down' argument. But I'm sure it is the correct syntax :
So, the syntax of my argument is correct, my code is correct. Where is the error located then ? Is there a specific way to handle the mouse, different than the keyboard ? I really don't think so, that's why I'm kinda confused here.
The way to debug this would be to print the held_keys dict to see what it contains. The correct name is 'left mouse'
. It is that way because the mouse button names are named differently than other keys and are mostly there to make code changes easier. Mouse buttons aren't keys after all.
However, what you could do is check mouse.left
instead.