timer and clk()? also Y=Y+90 use instead Y+=90
Hey it's me again,
I'm currently performing a "confuse yourself, build stuff" project which is meant to last about a week. As such i built a hoverplatform today. After about 6 hours of being confused now i only have one question left. The coloured part makes my platform turn, however it only turns by the entered amount and not further, i want it do to something like:
0 + 45 = 45
45 + 45 = 90
(I'd use smaller values then)
It'd also be nice if the platform kept the value afterwards
A big box of cookies for the first one to deliver me a useful answerCode:@inputs Numpad Active RightRoll LeftRoll Right Left PitchForward PitchBackward Space Num5 @outputs Plateforward:vector Gyro:angle @persist V:vector interval(10) Plate = entity() Me = owner() P = Plate:angles():pitch() Y = Plate:angles():yaw() R = Plate:angles():roll() V = (Me:pos() - Plate:pos() + vec(0,0,-22)) * 500 Plateforward = Plate:forward() if(Active == 1){ if(Space == 1){Plate:applyForce(Plateforward * 100)} if(Num5 == 1){Plate:applyForce(-Plateforward * 100)} if(Right == 1){Y = Y + 90} if(Left == 1){Y = Y - 90} if(RightRoll == 1){R = R + 45} if(LeftRoll == 1){R = R - 45} if(PitchForward == 1){P = P + 45} if(PitchBackward == 1){P = P - 45} Gyro = -ang(P,Y,R) * 100 Plate:applyAngForce(Gyro + $Gyro * 5) } if(Numpad == 1){Plate:applyForce( V + $V * 5)}
advance payment:![]()
Last edited by Peruanischer Speckkäfer; 07-02-2009 at 01:00 PM.
timer and clk()? also Y=Y+90 use instead Y+=90
.siht daer ot gniyrt emit detsaw ev'uoY
It's the same actually...i used += before but i was not sure whether it was the same.
Could you give an example for the timer code please?
Not really sure what you're asking, but that set of if statements is entirely unnecessary, replace it with something like
Plate:applyForce(Plateforward * 100*(Space-Num5))
Y += 90*(Right-Left)
R += 45*(RightRoll-LeftRoll)
P += 45*(PitchForward-PitchBackward)
ok still i want to make it turn like 10° left when i press left but don't want it to stop there, it should go on :/
Ok I think I got what you're saying - in that case,
P = Plate:angles()itch()
Y = Plate:angles():yaw()
R = Plate:angles():roll()
take these three lines out.
P.S. I wouldn't have $Gyro there if I were you - it'd be better done as Plate:angVel(), but also, if Right/Left/Rightroll etc is pressed it will screw that value up.
how is the chair meant to work without knowing it's own pitch roll and yaw?
Ah, I got you...you only want the yaw to be unrestricted? i.e. not at a specific degree? Then only delete this line
Y = Plate:angles():yaw()
and keep the other two in.
hmm, why does something like this not work? if(Right == 1){Y = Y + timer(TimerY,0)}
i want to add Y to the value of the timer
Validates in E2... Should workCode:@inputs Numpad Active RightRoll LeftRoll Right Left PitchForward PitchBackward Space Num5 @outputs Plateforward:vector Ang:angle runOnTick(1) Plate = entity() V = owner():pos() - Plate:massCenter() + vec(0,0,-22) Plateforward = Plate:forward() if (Active) { if (Space|Num5){Plate:applyForce((Plateforward * 100 * (Space - Num5)) * Plate:mass())} Ang = ang( (PitchForward-PitchBackward)*45, (Right -Left )*90, (RightRoll -LeftRoll )*45 ) Plate:applyAngForce(((-Plate:angles():setYaw(0)-Ang)*25-Plate:angVel()*5) * Plate:inertia():length()/sqrt(3)) } if (Numpad) {Plate:applyForce((V*10-Plate:vel())*Plate:mass())}
(\__/) Expression 2 Resources: E2 Beginner's Guide | E2 Formatting Guide | E2 Function Reference | E2 Examples | Me
(='.'=) PM me code and I'll send it back optimized if possible. (I find it fun dammit!)
(")_(") Drunkie referring to an E2: "It's obvious that Chinoto made this, his coding style is all over it."
Bookmarks