I wanted to add the .blend file as attachement (as stated in the post), but I get an error uploading it. What can I do about that?
Okay I’ll start with what I want it do do then I’ll point out where it goes wrong
I want a script that if you press and hold W the camera slowly tilts forward untill you reach about 70 degrees and if you keep holding the W key than you keep a steady 70 degrees descend.
I got pretty close myself, but there are a few kinks that I would like to improve.
So here is the code for the tilting (and leveling back to 90 degrees) when you hold the W key:
import GameLogic import bge cont = GameLogic.getCurrentController() own = cont.owner rotspeedWS = 0.00005 retspeed = 0.0001 move = cont.actuators["move"] W = cont.sensors["W"] Wbool = 0 Sbool = 0 e = own.orientation.to_euler() angleB = move.dRot if W.positive: print(e.x) if e.x > 1.2: angleB = angleB - rotspeedWS move.dRot = [angleB, 0, 0] cont.activate(move) Wbool = 1 else: Wbool = 0 if Wbool == 0: if angleB > 0: angleB = angleB - rotspeedWS move.dRot = [angleB, 0, 0] cont.activate(move) if angleB < 0: angleB = angleB + rotspeedWS move.dRot = [angleB, 0, 0] cont.activate(move) if e.x > 1.58: e.x = e.x - 0.004 own.orientation = e if e.x < 1.56: e.x = e.x + 0.007 own.orientation = e
And this works pretty smooth. You gradially tilt further forward till you hit 1.2 radians (about 68 degrees).
But when you keep holding it it flips out. because e.x constantly goes over and under 1.2 because of the 2 different if statements. (I added the .blend that shows that if you hold W after to 1.2 it flips out)
I don’t think I can explain it any better so please check the blend if you don’t know what I mean with “flip out” (haha)
If anyone knows a better way to get the result I want (the .blend shows precisly want I want, I just need a tweak at the 1.2 point so it doesn’t go berserk)
Don’t mind the awesome world creation in the .blend file
If you need any other information please ask and I’ll see if I can supply it.
Thank you if you read it all, I know it’s a long read.
Hoping for a reply