Strange bug

the lamp, was the child of the weapon manager,

so when the laser called
own.parent that is the weapon system (the gun)

so
for child in own.parent.children:

brings up a list, and looks for the property LP (LightPoint)
its the laser pointer dot,

so this all works, finds the lamp etc,

however when the object is duplicated it breaks,
even though the script is soft coded ,

it threw no errors,
it just did not work,

after sone digging I noted that the gun guts worked again after commenting out anything to do with moving the point light,

the laser scaler never worked, and thew no errors,

I used a different approach and had the weapon system emmit the lamp and it fixed all of it, including scaling the beam,

reported it as a ?? bug.

print statements indicated everything was running,
like it found the lamp,
the bullet was added etc,

however it just did nothing,

This really shouldn’t be reported as a bug when it’s most likely an error in the code. Unless you can upload something that shows the code & setup of what is being run, then it’s similar to asking an air-crash investigator what caused the crash before they’ve looked at the blackbox / wreckage

it throws no error, and at every step print (thing) yields the code is running.

found light, found addpoint, adding bullet etc,

then it’s like it goes into a black hole.

attaching a ‘flag’ to the point light yields it exists,

same with the laser beam,

so if everything is there, it prints it finds it, and all logic runs, and prints that its working, I don’t know where to go from there,

nothing is hard coded (it looks for properties in its children to assign them their roles) and the system works until duplicated… its just strange.

replacing move point light, with add point light fixed it…

so, ya…

I will see if I have permission to share the .blend, but I already worked around this particular error.

ok, I added the code, print(bullet.worldPosition)

and it’s way way out , not at the origin of the laser pointer :frowning:

if it’s user error I don’t understand it.

when I comment out the part about moving the lamp, the added position is correct,

when I un-comment it, the bullet is added way off near where I move the lamp when the laser is off?

I am moving the light, not the laser, and I am adding at the origin of the laser, so localScale should not matter? it seems like the scene graph to me, but I could be wrong?

My point is, unless you can allow people to investigate the error, it’s not sensible to report it, because we have no hope of fixing it!
I can’t add much more at this point.


##GunGuts
import bge
def root(gobj):
    if gobj.parent:
        return root(gobj.parent)
    else:
        return gobj


def main():


    cont = bge.logic.getCurrentController()
    own = cont.owner
    
    if own['Fire']!="Locked":
        if 'AddPoint' not in own:
            for child in own.childrenRecursive:
                if 'ProjectilePoint' in child:
                    own['AddPoint']=child
        else: 
            if own['Fire'] == -own['Reload']:
                bge.logic.getCurrentScene().addObject(own['ReloadSound'],own,0)
                print('Reload')
                
                ##Reload Code
                print(own['Owner'].name)  
  
                if own['Projectile'] in own['Owner']:
                    if own['Owner'][own['Projectile']=]=>own['ClipSize']:
                        own['Owner'][own['Projectile']]-=(own['ClipSize']-own['Mag'])
                        own['Mag']=own['ClipSize']
                    else:
                        own['Mag']=own['Owner'][own['Projectile']]
                        own['Owner'][own['Projectile']]=0   
                           
            if own['Fire']==1:
                ##Add bullet
                if own['Mag']>=1:
                    added=bge.logic.getCurrentScene().addObject(own['Projectile'],own['AddPoint'],own['Duration'])
                    added['Damage']=own['Damage']
                    added['Owner']=own['Owner']
                    added['Impact']=own['Impact']
                    own['Mag']-=1
                    own['Fire']=2
                else:
                     ##No bullets in clip
                    own['Fire']=-own['Reload']+1
                    bge.logic.getCurrentScene().addObject(own['EmptySound'],own,0)
                
            else:
                if own['Fire']!=0:
                     ##Sequencer
                    if own['Fire']<own['Rechamber']:
                        own['Fire']+=1
                    else:
                        own['Fire']=0        


   


main()




##Laser
import bge
from mathutils import Vector


def main():


    cont = bge.logic.getCurrentController()
    own = cont.owner
    own.applyRotation((0,0,bge.logic.getRandomFloat()*.1),1)
    if 'LP' not in own:
        ##Look up laser point light
        for child in own.parent.children:
            if 'LP' in child:
                own['LP']=child
                print('Child found')
            
            
    else:
        ##if the gun is equiped
        if own.parent.parent:   
            Ray=own.parent.rayCast(own.worldPosition+(own.worldOrientation*Vector([0,0,100])),own.worldPosition,0,'',0,0,0)
            
            if Ray[0]:
                ##if the ray hits, scale to the point as the laser is 1 unit long
                ##bge.render.drawLine(Ray[1],own.worldPosition,(1,0,0))
                D=own.getDistanceTo(Ray[1])
                own['LP'].worldPosition=own.worldPosition+(own.worldOrientation*Vector([0,0,D-.01]))
                own.localScale=(1,1,D) 
            else:
                ## if the laser does not hit scale to outside camera range
                ##bge.render.drawLine(own.worldPosition+(own.worldOrientation*Vector([0,0,100])),own.worldPosition,(1,0,0))
                own['LP'].worldPosition=own.worldPosition+(own.worldOrientation*Vector([0,0,100]))
                own.localScale=(1,1,100)          
        else:

            ##if your not equiped hide your light and scale to 0
            own['LP'].worldPosition=(9999,99999,99999)
            own.localScale=(0,0,0)
            
main()

btw I already worked around this,

I just want to make sure there is not something broken with the scenegraph

A few things;

  1. Without a test file, it’s still hard to do anything here. There are properties referenced in the scripts which aren’t set in the script, and it’s not clear what is going on.
  2. There are some mistakes in the first script, which makes it less clear what the issue was.

Once again, I would recommend using module mode

##GunGutsimport bge
def root(gobj):
    if gobj.parent:
        return root(gobj.parent)
    else:
        return gobj




def main(cont):
    own = cont.owner
    scene = own.scene
    
    if own['Fire'] == "Locked":
        return
        
    if 'AddPoint' not in own:
        for child in own.childrenRecursive:
            if 'ProjectilePoint' in child:
                own['AddPoint'] = child
                
    if own['Fire'] == -own['Reload']:
        scene.addObject(own['ReloadSound'],own,0)
        print('Reload')
        
        ##Reload Code
        print(own['Owner'].name)  
        owner = own['Owner']
        
        if own['Projectile'] in owner:
            if owner[own['Projectile']] >= own['ClipSize']:
                owner[own['Projectile']]-=(own['ClipSize']-own['Mag'])
                own['Mag']=own['ClipSize']
            else:
                own['Mag']=owner[own['Projectile']]
                owner[own['Projectile']]=0   
                   
    if own['Fire'] == 1:
        ##Add bullet
        if own['Mag']>=1:
            added=scene.addObject(own['Projectile'], own['AddPoint'], own['Duration'])
            added['Damage'] = own['Damage']
            added['Owner'] = own['Owner']
            added['Impact'] = own['Impact']
            own['Mag'] -= 1
            own['Fire'] = 2
            
        else:
             ##No bullets in clip
            own['Fire'] = -own['Reload'] + 1
            scene.addObject(own['EmptySound'], own, 0)
        
    elif own['Fire'] != 0:
         ##Sequencer
        if own['Fire'] < own['Rechamber']:
            own['Fire'] += 1
            
        else:
            own['Fire'] = 0       

well, the bug itself, is that the bullets are added somewhere between the laser origin, and the point light, even though they are do to be emmitted at the laser only,

Even so, the code might be fine but the file not, etc. If you’ve made a workaround fine, but if you want to work out the cause of the issue, we’ll need a test file :slight_smile:

I’ll ask the Original Developer :smiley:

https://drive.google.com/file/d/0B29hKf6-B52cUFFMUTBxS1VQWGM/view?usp=sharing

Done - All Art assets and animations are the property of the artists

Hanzo -(Mac 10)Free weapons giveaway

and The actor and animations are

@ChaosEmergency

All the code is mine, and I don’t care what you do with it, just don’t kill any puppies.

Ctrl = bring up mouse

right click = pick up weapon or stash in slot

left click = fire weapon

Controller pipes lists and mouse to actor, actor uses serialized input to locomote, and interact

Weapon system is triggerd by actor move filter, line 184

if 'Right' in own['Act'] and type(own['GunEmpty']['Weapon']) is not str:
            cont.activate(CamG)
            cont.deactivate(CamNG)
            if 'Left' not in own['Act']:
                ##Aim code
                cont.activate(cont.actuators[own['GunEmpty']['Weapon']['Aim']])
                
            else:
                 ## Fire Code
                 weapon=own['GunEmpty']['Weapon']
                 cont.activate(cont.actuators[own['GunEmpty']['Weapon']['Aim']])
                            
                 if type(weapon) is not str:
                     if weapon['Fire']==0:
                         weapon['Fire']=1

Anyone have any luck?

the only thing I can think, is that the property that I set, that points to the light, is loosing it’s target.

weaponmanager.children[‘Laser’][‘LP’]

Side note

You’ll need to provide more instructions on how to use the file, because trying to even get it to work is rather difficult.

I noted the players physics bound gets in the way of picking up stuff directly in front of you, it needs to conform to the plauer graphics better.

step 1, use ctrl+ right click to pick up the gun on the right
step 2 release ctrl, right mouse should now aim
step 3 left click while aiming should shoot.

try the exact same thing with the gun on the left,
(mac10)

I’m not sure what your setup is doing, but the laser isn’t where it should be, suggesting some scaling issue is going on.

comment out the part in laser, to move the point light

it fixes it for some reason
own[‘LP’].worldPosition=

(there are 3)

this is why its confusing, because the gun on the right is exactly like the gun on the left however, it does not work, even though nothing is hard coded.

So Goose, you confirm I found a strange bug?

try to avoid to set the scale at 0.0

i noticed time ago problems … ie the object not register more the collisions or something like this

0.00001 rather than 0.0 should work

I don’t think it’s a bug. I think that it’s a user error in the file, but the file is too complex to easily identify where the issue is.

A duplicate of a working system does not work,

nothing is different, except that its a duplicate,

nothing uses the point light, except the laser code,

I don’t see how its user error, using duplicate…

Gun 1 works, duplicate the gun, gun2 does not work and nothing is hard coded… :expressionless: