I donât know why it doesnât want to spawn/render in the map. Can someone please help me, Iâm so confused?
Thanks!
P.S if you see another post by me like this one but it got deleted, itâs because I messed up with the first post. Donât worry itâll delete in 24 hoursđ
As far as I see in your code above, youâre not generating any geometry: you âbeginâ the MeshDrawer (twice, actually), get the frame-time, and then âendâ the MeshDrawer without doing anything with it.
If you look at the MeshDrawer API, you should see a variety of methods for âdrawingâ various bits of geometry. (For a simple laser, the âsegmentâ method might be a good choice.) These are used between âbeginâ and âendâ to generate your intended geometry, I believe.
Youâre still not actually calling any of the mesh-generation methods that I mentioned in my previous post, as far as I see. ^^;
(I will note, by the way, that this looks like a less-efficient approach than you had previously. Previously, it looked like you were creating your MeshDrawer just once and using it as called for. Now youâre creating it every time you press âshiftâ, and destroying it every time you release âshiftâ.
(If you want your laser to not be drawn when âshiftâ is no longer held, you could simply hide the MeshDrawer NodePath, I believe.)
That said, this inefficiency may not be a major issue, depending on how your game performs otherwise, and the sort of hardware on which you intend it to run.)
Ah yes sorry about the approach, also this is my first time using mesh drawers could you maybe provide a little example of a mesh generation method and how to implement it into my code?
I did. I linked to the API documentation, told you where to place the code, and even recommended a method to consider for use as a laser. ^^;
PS: Donât worry about your code not being wonderfully efficient! If it works for you, it works! I just want to make sure that youâre aware of the potential efficiency, so that you can learn, I think.
Well, read through their descriptions, and tell me which you think is best suited to rendering a laser.
PS: To be clear, I donât mean that to be snarky. (And sorry if it comes across as so!) I just want to encourage you to improve at reading an API and drawing conclusions from it. A minor learning opportunity, so to speak.
unevenSegment (const LVector3 start, const LVector3 stop, const LVector4 frame, float thickness_start, const LVector4 color_start, float thickness_stop, const LVector4 color_stop)
Draws a segment a line with different thickness and color on both sides. MoreâŚ
I think thatâs all of them, maybe just the segment? IDK
PS youâre not snarky in any way, donât worry about it. Iâm a total nub at this lel
âSegmentâ is, I think, a good way of drawing a simple, straight âlineâ with a texture applied. It even has a billboarding effect that tries to keep its flat side visible to the camera, I believe. These points make it quite suitable, I feel, for drawing a laser.
One question though, right now the source of the beam is from the panda, and the target is always the other actor. This wonât make the game fun if you can automatically kill the actor, my question is how to make it so that the source is the panda but the target is just where the panda is facing. So you actually have to aim to direct the beam at the other actor.
any other way? Sorry if I sound snarky or anything, Iâm just wondering if there is a easier way that I can do with my code. Also wouldnât that just create a beam directed up?
Well, the easiest way is probably to not use a second object as your target-point, and just have your code construct the beam in a forwards-facing direction.
As to the direction of the beam in my suggestion above, that might somewhat depend on your code. However, if what you have is code that directs a beam from the player-character to a target-object, and if you place a target-NodePath ahead of the player-character, then the beam should end up pointing ahead of the character, it seems to me.
(Unless you thought that I meant overhead, it occurs to me? For the sake of clarity, in case thatâs the source of the confusion, I meant âaheadâ, i.e. âplaced in front ofâ.)
Donât worry about it: if I donât have time to answer, I likely wonât.
Iâm⌠not quite sure of what you mean when you ask which PandaNode Iâm referring to.
To start with, PandaNodes (that is, nodes) are separate things from NodePaths, albeit that the two are connected.
But more to the point, what Iâm suggesting is that you create an empty NodePath (with a PandaNode in it) to serve as your âtargetâ. Something like this:
# For the sake of the example, let's assume that your player-character's model
# is stored in the variable "self.myActor"; modify as appropriate to your code!
# Create a NodePath pointing to an empty node named "target"
self.targetNP = NodePath(PandaNode("target"))
# Attach the target NodePath to the player-character's model
self.targetNP.reparentTo(self.myActor)
# Place the target NodePath relative to the player-character's model
# Setting a NodePath's position without any additional arguments
# sets its position relative to its parent. In this case, it's a child of
# the player-character's model, and so this sets its position relative
# to the player-character's model.
self.targetNP.setY(5)
# (Adjust the distance as appropriate for your code)