I’m trying to rotate an object in the game engine that works of a property connected to an IPO.
First I have this for my script
[LEFT]import GameLogic as g
cont = g.getCurrentController()
owner = cont.getOwner()
sensors = cont.getSensors()
acts = cont.getActuators()
A=sensors[0]
D=sensors[1]
rot=acts[0]
if (A.isPositive()):
owner.rot -=0.1
g.addActiveActuator(rot,1)
elif (D.isPositive()):
owner.rot +=0.1
g.addActiveActuator(rot,1)[/LEFT]
I have a float property known as rot and an ipo that is set up for the rotation, i have ipo actuator set up for property so as rot goes up the ipo will go forward or as rot goes down the ipo will go back
i continually get the same error
PYTHON SCRIPT ERROR:
Traceback (most recent call last):
File “ShipMovement”, line 19, in ?
AttributeError: rot
This is all very reassuring, but I tried logic bricking for the IPO which could very well work. however I have trouble stopping the counter.
This is how it works. I want to make a Space Shooter game or something similar. Games like Tyrian or Super Star Soldier(think thats the name). And I have to get over some problems I’ve been having with the GE and writing python in it.
Right now I’m trying to figure out how to get the ship to rotate or tilt slightly when it moves left or right. And i found code similar to this, can’t seem to find it anymore, that does the same kind of idea. It would like the WASD to the script and when a button is pushed it tells the value rot to increment by -1 or 1 thus incrementing the IPO so it would rotate
thus logic bricking has some trouble so I can code the rest as soon as i figure out why it doesnt increment
The most probable reason why the property doesn’t increment is that the conditions of if/elif statements are never satisfied.
Check that simply putting a “print(“if statement passed/elif statement passed”)” in both blocks and see if the prints appear in the console.
Sorry for stupid question, I am using Blender from last 2-3 years, but game I seen today only.
I opend blender 2.42a and in the text window, i put first line
import GameLogic as g
and executed,
i got the Error
No Module Named GameLogic
what to do?
kkrawal,
Blender (the editor) does not know the module GameLogic. You have to assign your script to the logic bricks (controller) and start the Gameengine with ‘p’. The other way around: you souldn’t use the module Blender as this is not known to the blenderplayer (the standalone).
By the way you do not need to import the GameLogic it is already there you can directly access it e.g. GameLogic.getCurrentController().