Page MenuHome

Blender Game egine scripting error
Closed, ArchivedPublic

Description

System Information
Windows 7 64bit, Nvidia GTX 660 Ti

Blender Version
2.70

Short description of error
If I assign a new variable (for example posY for owner.position.y) it doesn't work

cont = bge.logic.getCurrentController()
owner = cont.owner
posY = owner.position.y
posY += 0.2

If I do the same thing without the last variable everything works just fine

cont = bge.logic.getCurrentController()
owner = cont.owner
owner.position.y += 0.2

Exact steps for others to reproduce the error

Create a text file with the following code

import bge

def main():
    cont = bge.logic.getCurrentController()
    owner = cont.owner
    owner.position.y += 0.2
main()

Add sensor Always. Activate TRUE level triggering
Add controller Python
Assign python to your text

The cube moves.

If you assign a variable to owner.position.y and set the variable += 0.2 then the cube doesn't move...

Event Timeline

Dalai Felinto (dfelinto) changed the task status from Unknown Status to Archived.Mar 24 2014, 2:55 PM
Dalai Felinto (dfelinto) claimed this task.

Python doesn't create a reference to the original property when you instance a float. It does if you do the whole array though:

cont = bge.logic.getCurrentController()
owner = cont.owner
position = owner.position
position.y += 0.2

It's not a bug, it's how things work, closing it.

Sorry.
I didn't know.
Thanks for the reply.