Hello World!!!
I make a puzzle game with blender game engine. It’s my fist experience for create a video game.
But I have a problem… I have a scene with a cube(the player) and a spikes. The spikes work when the cube hit them. When there is one spike only is good. But if there are several spikes, the last spike work only. Why???
It’s the file of my game.
Thank you for your answer!!!
Just remove the left one, shift d the right one and it work, but you need to handle the next error:
Python script error - object 'Piège', controller 'Python':
Traceback (most recent call last):
File "C:\Users\germe\Downloads\Briks.blend\Piege.py", line 29, in main
File "C:\Users\germe\Downloads\Briks.blend\Piege.py", line 11, in lever
SystemError: Cannot activate an actuator from a non-active controller
You need to pass the controller, just like the console says:
from bge import logic
cont=logic.getCurrentController()
own=cont.owner
chock=cont.sensors["Collision"]
own["state"]='Baissé'
state=own["state"]
def lever(cont):
cont.activate(cont.actuators["Levé"])
def Baisser(cont):
cont.activate(cont.actuators["Baissé"])
def Mort(cont):
cont.activate(cont.actuators["Mort"])
def main(cont):
global state
if chock.positive:
own["Chock"]=True
else:
own["Chock"]=False
if chock.positive and state=="Baissé":
lever(cont)
state="Levé"
own["Time"]=0
if chock.positive and state=="Levé" and own["Time"]>0.5:
Mort(cont)
state="Baissé"
if state=="Levé" and own["Time"]>1.5:
Baisser(cont)
state="Baissé"
Hello Cotaks!
Where is the problem? In my logicEditor? Yes I know. It’s the sensor “Collision”, who not active evrytime, who make the problem. But I don’t know how solve this…
use the script i posted, compare it with yours, you see that i passed the controller (cont) in the functions.
Oh yes Thank you Cotaks!
But know there is an other problem: the collision spikes and player works for one pike only…
I duplicated spike with Shift-D (normal) but the collision isn’t detected…
What the hell?
I change a little the sensors in the logic Editor as this:
This version is save in Github.
Thanks for you answer