I did not say that he was wrong, I noticed that this post is about else. The task you created looks different. You want to detect a collision differently. I have given a short code with a ray. In your understanding, there should have been geometry instead of a ray (your meshdrawer ray) This is another problem for which I have no solution.
What do you mean? When did I say this?
Here you go. It seems clear to say.
Yeah, I don’t understand what you mean by geometry instead of ray. What are you talking about here?
meshdrawer - this is a mesh (polygons, model)
Yeah but why did you say to solve it by adding geometry or something instead of the ray for detecting?
This problem is solved through CollisionRay. That is, a collision system. You started to create a game without understanding how everything happens. Making a game is like a movie, solid Hollywood.
Can you explain what a CollisionRay is and why I need to use it?
I would like to clarify what is your meshdrawer for? As far as I remember from your posts this ray - yes?
the meshdrawer is a beam that shoots from the player when shift button is pressed, right now tho it dooesn’t do any damage or anything. That’s why I want to detect it so it can kill the enemy/ai.
This is essentially a blaster weapon. You can use other elements for the shells as a capsule or sphere and, accordingly, a ray. I think you also need to learn what a hitbox is in games in order to properly customize your character.
Next, I think you need to ask questions in another topic and specifically describe the essence of the task.
Why can’t I use what I have right now? It works perfectly fine,
In games, there is a visual component and a mathematical part. You solved the problem visually, but did not think how to calculate the hit. You do not need to do otherwise, now your task is to combine the visual part with the mathematical part. The mathematical part is not visible, it is under the hood.
from direct.showbase.ShowBase import ShowBase
from direct.showbase.DirectObject import DirectObject
from panda3d.core import CollisionTraverser, CollisionHandlerQueue, CollisionNode, BitMask32, CollisionRay
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
base.cTrav = CollisionTraverser()
collHandler = CollisionHandlerQueue()
ralph = loader.loadModel("smiley")
ralph.setCollideMask(BitMask32(1))
ralph.reparentTo(render)
pointerNode = render.attachNewNode("Main Collider")
pointerNode.setPos(0, 0, 15)
raySolid = CollisionRay(0, 0, 0, 0, 0, -1)
collNode = CollisionNode("collNode")
collNode.addSolid(raySolid)
collisionNodepath = pointerNode.attachNewNode(collNode)
mainCollisionNode = collisionNodepath.node()
mainCollisionNode.setFromCollideMask(BitMask32(1))
base.cTrav.addCollider(collisionNodepath, collHandler)
app = MyApp()
app.run()
Now it is not visible how the collision is calculated, but it is.
The mathematical part would be the collision detection?
Namely, this is magic that is not visible to the eye, in games what you see is done as optimized as possible.
Instead of a player, a sphere for hitting.
Instead of legs, a ray.
Instead of weapons, again a ray or other elements of the collision system.
Usually:
The player is a big sphere.
Bullets are small spheres.
But there are games more complex, with elaborate hitboxes.
Ok so then how do I make this collision detection system for the ray?
It all depends on what your models look like, what features are needed. Here you need to build on the concrete appearance and mechanics of movement.
so should I send my code over because I have no idea?
I think you need education.
I think you need to be more professional like @rdb said, do you even know what task I’m trying to complete, what I’ve been talking about these last few hours on this forum?