0
$\begingroup$

I am having a hard time trying to manipulate the rotation of every object on a list:

import bge
import bpy

cont = bge.logic.getCurrentController()
own = cont.owner
scene = bge.logic.getCurrentScene()

keyboard = bge.logic.keyboard #Declare Keyboard
wKey = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.WKEY] #Declare Keys
sKey = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.SKEY]
dKey = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.DKEY]
aKey = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.AKEY]
spaceKey = bge.logic.KX_INPUT_JUST_ACTIVATED == keyboard.events[bge.events.SPACEKEY]

wKey_rel = bge.logic.KX_INPUT_JUST_RELEASED == keyboard.events[bge.events.WKEY]

cubes = (scene.objects["Cube.3"], scene.objects["Cube.4"])
for x in cubes:
    if spaceKey:
        x.applyRotation((0,.1,0), False)
        cubes.append(scene.objects["Cube.5"])
        print(cubes)
        break

The thing is that it works, but it only applies rotation to the first object and if I use x[0:3] or cubes[0:2] it doesn't work at all. What I am doing wrong?

$\endgroup$
1
  • $\begingroup$ never ever import bpy! - It is the Blender API which is not available within the final game. $\endgroup$
    – Monster
    Commented Jan 25, 2018 at 5:28

1 Answer 1

0
$\begingroup$
  1. AttributeError: 'tuple' object has no attribute 'append'

  2. You explicitly break your loop.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .