Strange bug with alpha planes

Upon doing some testing I’ve noticed that randomly, alpha planes will act very weird. There appears to be no single reason that this happens… however, it only seems to happen if the ship in the back is shooting. That alone is very strange, because they all use the exact same code (they are their own objects however). At first I thought maybe it was just a coding mistake, and that the endpoints were inaccurate, but again, the bug only happens if the ship in the back is shooting; if the two on the sides fire at the same time, they are accurate, but if the one in the back shoots with them, one or more of the lasers will appear buggy.




Also, I don’t know if it’s just my graphics card (I am doubtful) but depending on the camera angle the lasers also seem to dissapear completely.

Has anyone had this problem before? And is there a solution? I would really like to stick with BGE because I absolutely love how easy Python is, but more and more small problems like this are starting to drive me away.

Also, if I add more ships and tell them to shoot as well, they will all appear to start bugging out like that. (however, you can see for a brief period of time that they all hit the correct spot, and then the just flash randomly into the wrong spot when another ship decides to shoot) … I’m convinced that it’s a problem with the game engine.


Edit: Could it possibly be a problem with linux video drivers?

How are you placing the planes? or are the lasers something else?

you may consider placing a cylinder with the top and bottom deleted at the mid point of the “cannon” and the “impact site” and scaling it accordingly,

Cannon }--------------------> (impact site)
Cannon(p1)-------------------(p2)

p3.x=(p1.x+p2.x)/2
p3.y=(p1.y+py.y)/2
p3.z=(p1.z+p2.z)/2

cannon-----------p3-------------(impact site)
cannon============(impact site)

This is how I’m placing the planes. But like I said, the bug only happens when more than 2 (usually) ships are firing their lasers. Otherwise it works perfectly and lands exactly where it should.

import math

def manageEndPoints(laser, ship):
    if laser['laser'] is True:  #This is inside the turret script but only needs to be used if the weapon is a laser
        mesh = laser.meshes[0]
        target = ship.target.obj
        #print(target)
        base = laser.parent #This is the barrel of the gun
        offset = (base.position.x - ship.obj.position.x) #Get the actual hardpoint position
        if offset < 0: #If it's on the negative side of the ship, account for that
            offset = offset * -1 #No negatives!

        #3d distance formula
        d =  math.sqrt((base.position.x - target.position.x)**2 + (base.position.y - target.position.y)**2 + (base.position.z - target.position.z)**2)
        
        #Get the front 4 verts of the laser
        v1 = mesh.getVertex(0,0)
        v2 = mesh.getVertex(0,1)
        v3 = mesh.getVertex(0,4)
        v4 = mesh.getVertex(0,5)
        
        v1P = v1.getXYZ()
        v2P = v2.getXYZ()
        v3P = v3.getXYZ()
        v4P = v4.getXYZ()
        
        #Move them to enemy position, accounting for the position of the hardpoint
        v1P.y =  d - offset
        v2P.y =  d - offset
        v3P.y =  d - offset
        v4P.y =  d - offset
        
        
        v1.setXYZ(v1P)
        v2.setXYZ(v2P)
        v3.setXYZ(v3P)
        v4.setXYZ(v4P)

???

Cannon }--------------------> (impact site)
Cannon(p1)-------------------(p2)

p3.x=(p1.x+p2.x)/2
p3.y=(p1.y+py.y)/2
p3.z=(p1.z+p2.z)/2

cannon-----------p3-------------(impact site)
cannon============(impact si

Whats that…

Its positioning the lazer half way between the cannon and hit site.

tbh im not sure this is the most efficient method of doing lazers.

wouldn’t it be easier to set the Lazer origin pivot at the very start of the plane have the plane hidden when not firing.

when its time to fire unhide the plane set the orientation to the firing direction, calculate the distance and scale accordingly.

this way you could do a small animation while firing. I’m sure this is how eve online does it or similar from observations

CTBM

yep but as far as I can tell there’s no scale method for KX_GAMEOBJECT
you can see at the end of this video that they don’t appear to be bugging… it’s just weird.

i believe its Scaling.

http://www.blender.org/documentation/blender_python_api_2_65_release/bge.types.html?highlight=gameobject#bge.types.KX_GameObject.scaling

not sure if this is what your looking for.

BTW I’m liking your game atm can’t wait to see how it comes along.

also how are you using alpha texturing? are you using alpha clip or sort?

on the materials tab? opaque* (made a typo in previous post), also using nodes

Alpha blend might cause some issues if you stack planes. when layering a lot of planes clip seems the most robust however isn’t the most nice looking.

Try playing with the settings and see if you can fix your issue.

Hey thanks a ton! Previously I believe it was on Alpha Blend, I switched it to opaque by accident (because I clicked it and forgot what the default was haha) and that fixed the flickering issue, also the scaling works great (so I was correct in thinking it was a BGE problem… with the vert.setXYZ methods I suppose?) also that works out great because scaling will always be reliable whereas setting vert positions relied on those positions corresponding to the endpoints.

I don’t know how I keep missing these methods (scaling, etc) because whenever I do a google search or an API search, nothing comes up. Maybe I’m looking at a way out of date API… ?)

And hey if you ever need any help, don’t hesitate to send me a message! You’ve just saved me from hours of frustration haha :slight_smile:


solved problems are the best kind to have :slight_smile: