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.