Help! Tell me what's happening here!
Blitz3D Forums/Blitz3D Programming/Help! Tell me what's happening here!
| ||
Here's a really odd thing! I apparently have an integer value which changes of its own accord... or perhaps some strange Blitz blip not adding correctly. Let me explain: In my game ( a side scrolling platformer) the player can only turn left or right - 90 or 90 degrees ie. only 180 degrees either way. On land his 'turn' variable is set to 12 degrees...in water he turns slower at 6 degrees. Note that both integer values neatly divide into 180. The problem I have is that the rotations are going out of synch by strange steps - 10, 15 etc and then they remain screwed up!! Please look at the screen shot - the debuglog tells it all and captures the moment when the rotations go weird. Environment tells me where I am : 2 is in water 1 is on land -1 is a special water exit routine that will finish off any on going 'left or right' rotations whilst leaping out of the water (or simply process any new turns as usual that may have been initiated). These need to be completed as the 'turn' value will change to 12 on land and would not otherwise finish rotating either on -90 or 90 degrees if the two different turn values are intermingled during a single Y rotation. Water & Special rotations tells me the player's Y rotation value and it's by reading down this list we can spot a turn in progress and then see it go out of synch! ..and this even while the actual turn value is displayed as a correct number; in this case '6'. Read down far right numbers on the list until you come to 97! It's bloody impossible!! I'm supposed to be adding 6 to the value of 90 and get 97??? Can anybody tell me what's going wrong here? It's got me chewing the desk I'm at here! Could tweening upset these calculations at all? Though it simply doesn't show in the debuglog. ![]() |
| ||
Can we see some code? |
| ||
> Could tweening upset these calculations at all? If you are tweening then the answer is yes. If you are actually using fractional variables to handle the tweening then the imprecision of floating point will cause this problem. Although seeing the code will certainly help to prove it or not. |
| ||
Okay - sorry for not putting relevant code here in the first place - here's the actual 'special water exit' function that sends the rotations out of synch. Dynaman - if it is the tweening what can I do to get this working right? |
| ||
Anybody have any ideas? |
| ||
I had a problem similar to this, I switch from 'tweening' to 'delta T' and it solved the synchro problems. Otherwise, if you prefer to use tweening, try to position the object after updateworld. |
| ||
Thanks - I'll look into that |