Variablen Problem
Übersicht

Cedric30003Betreff: Variablen Problem |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hey Leute!
Ich habe in gemeinschaft mit PhillipB. mich mit EntityYaw beschäftigt. Nun haben wir eine "Falttür" ausprobiert, welche im Grunde funktuiniert, aber sobald wir den Float auf "0" setzen wollen, kommt da irgendeine 0.499994 oder ähnliches heraus. Bzw. das Objekt wird von 85 wieder auf 0 zurück gedreht. Um das ganze evt verständlicher zu machen hier der Code inkl. Objekte: http://supportwbb.su.ohost.de/...c3%bcr.zip (Oben links werden die variablen angezeigt) Code: Code: [AUSKLAPPEN] Graphics3D 800,600,32,2
SetBuffer BackBuffer() flugel_l = LoadAnimMesh ("fluegel_l.3ds") flugel_r = LoadAnimMesh ("fluegel_r.3ds",flugel_l) timetimer = CreateTimer(60) PositionEntity flugel_r,0,0,2.9855 ;Kamera Global cam1=CreateCamera () PositionEntity cam1,0,3.5,0 MoveEntity cam1,-10,10,0 RotateEntity cam1,0,-90,0 Rotspeed_l# = 0 Rotspeed_r# = 0 ;Tür Variablen bzw auf = 1 zu = 0 tür1 = 0 Function Kamera() ;Kamera drehen If MouseDown (2) TurnEntity cam1,-MouseYSpeed()/4,0,0 TurnEntity cam1,0,-MouseXSpeed()/4,0,1 MoveMouse GraphicsWidth()/4,GraphicsHeight()/2 EndIf ;[Block] Freie Kamerabewegung ;bewegen If KeyDown(17) And KeyDown (42) Then MoveEntity cam1, 0, 0, +0.5 EndIf If KeyDown(17) Then MoveEntity cam1, 0, 0, +0.02 EndIf If KeyDown(31) Then MoveEntity cam1, 0, 0, -0.02 EndIf If KeyDown(32) Then MoveEntity cam1, +0.02, 0, 0 EndIf If KeyDown(30) Then MoveEntity cam1, -0.02, 0, 0 EndIf ;Kamera hoch und runter If KeyDown(16) Then TranslateEntity cam1, 0, 0.05, 0 EndIf If KeyDown(18) Then TranslateEntity cam1, 0, -0.05, 0 EndIf ;[End Block] End Function While Not KeyHit (1) Kamera() TurnEntity flugel_l,0,Rotspeed_l,0 TurnEntity flugel_r,0,Rotspeed_r,0 If KeyHit (28) Then tür1 = 1 - tür1 EndIf If tür1 = 1 Then Rotspeed_l = - 0.5 Rotspeed_r = 1 If EntityYaw (flugel_l) < - 85 Then Rotspeed_l = 0 EndIf If EntityYaw (flugel_r) > 169 Then Rotspeed_r = 0 EndIf If KeyHit(28) Then EmitSound (tuer_zu,flugel_l) EndIf EndIf If tür1 = 0 Then If EntityYaw (flugel_l) > 0 Then Rotspeed_l = 0 ElseIf EntityYaw (flugel_l) = 0 Then Rotspeed_l = 0 Else Rotspeed_l = 0.5 EndIf If EntityYaw (flugel_r) < 0 Then Rotspeed_r = 0 ElseIf EntityYaw (flugel_r) = 0 Then Rotspeed_r = 0 Else Rotspeed_r = - 1 EndIf EndIf UpdateWorld RenderWorld Text 10,10, EntityYaw (flugel_l) Text 10,20, EntityYaw (flugel_r) Flip 0 WaitTimer timetimer Wend End Danke im Voraus MfG Cedric & Phillip |
||
Windows 7 Enterprise (x64) | AMD Athlon II X4 620 (4x2,61GHz) | 8GB RAM | nVIDIA GeForce 9500GT (1024MB) |
![]() |
Propellator |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hi,
Hierbei handelt es sich um simple Float-Fehler. Woran liegt denn genau das Problem, nur daran dass die Zahl seltsam aussieht? Runden könnt ihr nämlich je nach Bedarf mit Floor ![]() ![]() ![]() |
||
Propellator - Alles andere ist irrelephant.
Elefanten sind die Könige der Antarktis. |
Cedric30003 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Der Problem liegt halt darin, dass wir das Objekt zurückdrehen wollen, aber die Rückdrehung bleibt immer ein kleines Stück vorher stehen.
MfG Cedric |
||
Windows 7 Enterprise (x64) | AMD Athlon II X4 620 (4x2,61GHz) | 8GB RAM | nVIDIA GeForce 9500GT (1024MB) |
![]() |
XeresModerator |
![]() Antworten mit Zitat ![]() |
---|---|---|
Bei Fließkommazahlen kann man nie von exakten Werten ausgehen. Benutzt ein Int und teilt bei Benutzung durch die passende Zehnerpotenz. | ||
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus THERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld) |
![]() |
Midimaster |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ihr könnt beim Verwenden von Float-Variablen nicht davon ausgehen dass eine genauer Wert 0 jemals erreicht wird. Korrigiert die Schließwinkel, sobald der Vorgang beendet wird:
Beispiel: BlitzMax: [AUSKLAPPEN] If EntityYaw (flugel_r) <0 Then |
||
Gewinner des BCC #53 mit "Gitarrist vs Fussballer" http://www.midimaster.de/downl...ssball.exe |
Cedric30003 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Danke schonmal für eure bemühungen! Ich werde das nacher am pc mal austesten. Klingt aber jedenfalls logisch. (bin gerade nur mobil online)
Mfg cedric |
||
Windows 7 Enterprise (x64) | AMD Athlon II X4 620 (4x2,61GHz) | 8GB RAM | nVIDIA GeForce 9500GT (1024MB) |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group