I got the issuse. I forgot to add drag(self, task) to the taskMgr. But now I am getting this error:
Traceback (most recent call last):
File âC:\Users\Rahul\AppData\Local\Programs\Python\Python38-32\drag.pyâ, line 53, in
game = Game()
File âC:\Users\Rahul\AppData\Local\Programs\Python\Python38-32\drag.pyâ, line 34, in init
self.taskMgr.add(self.drag)
File âC:\Users\Rahul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\direct\task\Task.pyâ, line 394, in add
task = self.__setupTask(funcOrTask, name, priority, sort, extraArgs, taskChain, appendTask, owner, uponDeath)
File âC:\Users\Rahul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\direct\task\Task.pyâ, line 413, in __setupTask
self.notify.error(
File âC:\Users\Rahul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\direct\directnotify\Notifier.pyâ, line 130, in error
raise exception(errorString)
Exception: add: Tried to add a task that was not a Task or a func
Simply put, youâre never telling your traverser to traverse the scene-graph.
Although youâre also missing a parameter in your âsetDragâ function: remember that a collision-event will include a collision-entry parameter, as well as whatever other parameters you specify (in this case a boolean value).
By the way, you donât need to âacceptâ your âpicker-into-smileyâ event every time that you clickâjust doing so once should be enough. Unless you intend to remove the event under some condition or another, of course!
(There are a few other things that will call for fixing, it seems, but for now Iâll leave those for you to find and figure out!)
Exactly. Or just set the x- and z- coordinates separately.
But (A) youâll likely learn more if you figure it out for yourself, and (B) itâs not really fair for me to have to do all of your work, and (C) itâs Sunday, a day on which I rest.
Iâm happy to help you, and especially to help you to learnâbut just doing it all for you is a bit much, I feel.
Also, I just learned that on this forum, if you enter (C) you end up with a copyright symbol! (C) XD
OK, whatever. Now I changed my code to what you told. But it is dragging awfully slowly. And I canât drag continuously after I stop dragging. I have to first click, like the problem with many of my collision queries. And when I do all of that, and try to drag again, It goes back to (0, 25, 0)
And also, the smiley is behind the mouse even though moving. I want it to be exactly where the mouse is
Have you tried printing out the values given by âmouseWatcherNode.getMouse()â? That should tell you where the problem lies.
Hmm⌠Iâm not quite sure of what problem youâre describing here. Is click-and-drag not what you want? If not, could you explain again please what it is that you want to have happen?
I suspect that this is connected to the first problem that I addressed aboveâletâs see whether fixing that also fixes this.
I am talking about the problem in this one: Clicking on a 3D object. Read it and you will find when I said that I need to click on an object, then click outside so that I can re-click.
Ah, I see. Well, we also discussed the reason for that in the same thread, I believeâsee this post, specifically. (After the quote âThatâs right So how to fix it?â.)
Thatâs not quite what I said there, I think, but it could probably be made to work, I imagine. Personally, I favour the bitmask-solution that I suggested, or using a CollisionHandlerQueue.