How to activate beam?

So far I have implemented a beam effect that is activated whenever the shift button is pressed. How do I make it so that if you click somewhere on the screen the beam will follow?

here is a code snippet:

self.accept("shift", self.handleShift, [1])
self.accept("shift-up", self.handleShift, [0])

    def handleShift(self, arg):
        if arg == 1:
            self.source = self.pandaActor
   = self.plant

    def createBeam(self, source, target):
        self.generator = MeshDrawer()
        self.generatorNode = self.generator.getRoot()
        beamtex = self.loader.loadTexture("/Users/38167/PycharmProjects/viren/venv/wood.jpg")
        self.generatorNode.setPos(-0.3, 2, 2)
        self.taskMgr.add(self.drawBeam, "drawBeamTask", extraArgs=[source, target], appendTask=True)

    def drawBeam(self, source, target, task):
        t = globalClock.getFrameTime()
        self.generator.begin(, self.render)
        self.generator.segment(Vec3(self.source.getPos()), Vec3(, Vec4(0, 0, 1, 1), 0.3, Vec4(1, 1, 1, 1))

        return task.cont

    def deleteBeam(self):


Do you think this is the way to learn programming?

1 Like
  1. What do you think this forum is for?
  2. Do you think you’re helping?
  3. To answer your question, I learn from the best so yes


I’ve been thinking about this a bit, and it seems to me that what you could really use is a tutor: someone who can sit with you (whether in-person or online) and go through the elements of building a simple game step-by-step.

Perhaps if you make a posting offering a paid tutorship, you might find someone willing to help you in this way; someone willing to invest a significant portion of time in helping you.

Right now you’re asking people to give you quite a lot of help, not only for free, but out of their spare time. This may be why people are starting to get a bit short-tempered with you.

sorry about that… I guess so, I’m currently broke right now and can’t afford one at the moment. I’ll try to stop posting frequently then as I didn’t realize how much trouble I was causing in this community.


Then my best suggestion to you, if I may, is this: set aside your current game for about a week, and go through a full Panda3D tutorial. It means time away from your game, but you’ll hopefully learn a lot of the basics that you’ve been struggling with, and you may well find that you come back to your game much more ready to implement the features that you want. (And you may find yourself building your game faster, too, in the long run.)

(For one thing, aside from jumping, nearly everything that you’ve been asking of late is covered in my own “beginner’s tutorial”, in detail and with example code. I don’t say that to encourage you to my tutorial specifically; it’s just (naturally) the one that I know best.)

The problem is not what you ask, the problem is that all of this is described in detail in the manual … but in the end we must duplicate their contents on the forum for you.

The answer to your question.

Also this lesson from my tutorial:

By the way, about your textbook, it would be great if the forum administration added a link in the header to this textbook and other useful materials, cheat sheets, etc. with a title for a beginner beginner.

It actually is mentioned in the new manual, I believe! :smiley:

Let me get the link…


So once the new manual is linked on the site, it should at least be referenced there. :slight_smile:

Although, now that I think of it, a sticky forum-thread perhaps isn’t a bad idea–it’s a place that a new user may well look before turning to the manual. The thread might even simply link to the relevant part of the new manual.

I saw a new guide, and saw your textbook. However, I meant a little something else:

posting links in this style is very convenient when you answer a question.

I take it that you’re referring to threads like “How to type code blocks”, near the top of that page? Indeed, I think that would be useful.

Yes, it is always before your eyes, a beginner will also be useful to those who respond to the forum.

Indeed–some may not even look at the manual before going to the forum.

Perhaps start a new thread proposing this? It’s a little off-topic here, and may be missed by the mod(s). (… I’m honestly not sure of how many mods we have here, come to think of it. ^^; )

There was a topic on updating the site in which I suggested this, but it was lost. I think that important topics should be fixed on top.

Yup, that does indeed seem like a good idea.

I still think that starting a new thread, for this purpose specifically, might be worth doing! The suggestion from the original thread may have been forgotten, especially if it wasn’t part of the central purpose of that thread.

Sorry if I sounded harsh, but I see you asking for help every day, and this is really not a method, if you want to know how program a computer game yourself. You won’t be able to get help everytime you need it. E.g. Panda froums went down (it happens sometimes). Or you didn’t pay your Internet bill and have no access to the Web, etc.

  1. Become a confident Python user. Apart from official Python docs, there is a lot of learning materials
  2. Learn how to program basic 2D stuff, e.g. with Pygame. There’s some online reading as well:
  3. Learn the basics of maths that is required for gamedev - linear algebra (vectors), trigonometry, matrices, probably quaternions (though they can be hard to grasp).
  4. Learn basic algorythms and patterns used in video games. Like collision detection, pathfinding, random generation, etc.
  5. Read Panda3D manual. Keep it around to come back to it.
  6. Complete some of Panda3D tutorials. Apart from Thaumaturge’s tutorial, there’s not much, but still is:
  7. Search the forums. Chances are the topic was discussed earlier.

I don’t recommend video tutorials, but that’s only me (in my opinion they take too much time).

If you have already completed all these steps, then try to write down what you want to achieve not in code, but in words. E.g. “when the mouse “click” event is registered, I want to change the coordinates of my beam model each tick of the game loop”.

Then try to look in the Panda manual and try to reproduce this in code. How to listen for events? OK, here’s a DirectObject class and it’s “accept” method. How to change the coordinates? OK, here’s a bunch of NodePath methods for this, etc

Again, sorry if my advice is not needed and you already know all this.