shoffing
(shoffing)
1
I dont get why this doesnt change levels when i touch the “finish” material. Help!
cont = GameLogic.getCurrentController()
own = cont.getOwner()
#Sensors
forward = cont.getSensor("Up")
backward = cont.getSensor("Down")
left = cont.getSensor("Left")
right = cont.getSensor("Right")
jump = cont.getSensor("Space")
nextlevel = cont.getSensor("Finish")
#Actuators
motion = cont.getActuator("motion")
scene = cont.getActuator("scene")
#Process
speed = 0.07
rspeed = 0.02
height = 5
walk = 0
turn = 0
playerjump = 0
Level2 = 0
if forward.isPositive():
walk = speed
if backward.isPositive():
walk = -speed
if left.isPositive():
turn = rspeed
if right.isPositive():
turn = -rspeed
if jump.isPositive():
playerjump = height
if nextlevel.isPositive():
scene.setScene(Level2)
motion.setDLoc(walk, 0, 0, 1)
motion.setDRot(0, 0, turn, 1)
motion.setLinearVelocity(0, 0, playerjump, 1)
GameLogic.addActiveActuator(motion, 1)
shoffing
(shoffing)
2
Sorry i messed up typing on the code heres the real code:
cont = GameLogic.getCurrentController()
own = cont.getOwner()
#Sensors
forward = cont.getSensor("Up")
backward = cont.getSensor("Down")
left = cont.getSensor("Left")
right = cont.getSensor("Right")
jump = cont.getSensor("Space")
nextlevel = cont.getSensor("Finish")
#Actuators
motion = cont.getActuator("motion")
scene = cont.getActuator("scene")
#Process
speed = 0.07
rspeed = 0.02
height = 5
walk = 0
turn = 0
playerjump = 0
if forward.isPositive():
walk = speed
if backward.isPositive():
walk = -speed
if left.isPositive():
turn = rspeed
if right.isPositive():
turn = -rspeed
if jump.isPositive():
playerjump = height
if nextlevel.isPositive():
scene.setScene(Level2)
motion.setDLoc(walk, 0, 0, 1)
motion.setDRot(0, 0, turn, 1)
motion.setLinearVelocity(0, 0, playerjump, 1)
GameLogic.addActiveActuator(motion, 1)
and i get this error message when i reach the finish:
File “GameScript”, eline 39, in <module> NameError: name ‘Level2’ is not defined