fantomEngine: SetSpeed reports absolute speed?
Monkey Forums/User Modules/fantomEngine: SetSpeed reports absolute speed?
| ||
Hi, @MikeHart or anybody else who knows more about the workings of ftEngine than I do. I have simple Tank drive-around code that works beautifully. It's set up for WASD, but there's a weird wrinkle with Reverse. In my code, W adds to the forward speed and it works as expected. A and D, do the expected things to the angle. But S, which subtracts from the forward speed (meant to be a brake, and once stopped, a reverse) has a weird behavior. It works, initially, as expected, but very quickly, it "bounces", meaning the reversing vehicle changes direction, momentarily. If I monitor ftObject.GetSpeed, it looks "kind of" as expected-- except it's reporting +3.00 the same as -3.00. There is some output below that shows the bouncing. The code is simply adding a negative number to the current speed (using AddSpeed) when the player is holding down the Reverse key. The bouncing is much MORE pronounced if I have my MaxSpeed code turned on, but it still happens a little bit even without the MaxSpeed code on. What I would expect to see is that there would be a negative number at some point-- as the speed is negative (in one sense) because the angle remains the same. However, the speed reported is always positive, even though it's being treated properly internally. What I think is happening is that when the GetSpeed (secretly negative) reports above the MaxSpeed allowed, the code that fixes the speed at MaxSpeed is setting it to +MaxSpeed, even though, secretly, the speed is at -GetSpeed. R: GetAngle/Speed from player tank: 174.0/15.033331871032715 R: GetAngle/Speed from player tank: 174.0/13.483333587646484 R: GetAngle/Speed from player tank: 174.0/12.050000190734863 R: GetAngle/Speed from player tank: 174.0/10.550000190734863 R: GetAngle/Speed from player tank: 174.0/9.0833349227905273 R: GetAngle/Speed from player tank: 174.0/7.600001335144043 R: GetAngle/Speed from player tank: 174.0/6.1333346366882324 R: GetAngle/Speed from player tank: 174.0/4.6333346366882324 R: GetAngle/Speed from player tank: 174.0/3.1833348274230957 R: GetAngle/Speed from player tank: 174.0/1.6833348274230957 R: GetAngle/Speed from player tank: 174.0/0.21666812896728516 R: GetAngle/Speed from player tank: 174.0/1.2000001668930054 R: GetAngle/Speed from player tank: 174.0/2.133333683013916 R: GetAngle/Speed from player tank: 174.0/3.0333335399627686 R: GetAngle/Speed from player tank: 174.0/3.9833335876464844 R: GetAngle/Speed from player tank: 174.0/4.883333683013916 R: GetAngle/Speed from player tank: 174.0/5.8166661262512207 R: GetAngle/Speed from player tank: 174.0/6.7333321571350098 R: GetAngle/Speed from player tank: 174.0/7.649998664855957 R: GetAngle/Speed from player tank: 174.0/8.5666656494140625 R: GetAngle/Speed from player tank: 174.0/9.5166654586791992 R: GetAngle/Speed from player tank: 174.0/10.416665077209473 R: GetAngle/Speed from player tank: 174.0/11.349998474121094 R: GetAngle/Speed from player tank: 174.0/12.266664505004883 R: GetAngle/Speed from player tank: 174.0/13.199997901916504 R: GetAngle/Speed from player tank: 174.0/14.099997520446777 R: GetAngle/Speed from player tank: 174.0/15.049997329711914 R: GetAngle/Speed from player tank: 174.0/13.5 R: GetAngle/Speed from player tank: 174.0/12.033333778381348 R: GetAngle/Speed from player tank: 174.0/10.550000190734863 R: GetAngle/Speed from player tank: 174.0/9.0833349227905273 R: GetAngle/Speed from player tank: 174.0/7.5833353996276855 R: GetAngle/Speed from player tank: 174.0/6.133336067199707 R: GetAngle/Speed from player tank: 174.0/4.633336067199707 R: GetAngle/Speed from player tank: 174.0/3.1666691303253174 R: GetAngle/Speed from player tank: 174.0/1.6666690111160278 R: GetAngle/Speed from player tank: 174.0/0.21666896343231201 R: GetAngle/Speed from player tank: 174.0/1.2000001668930054 R: GetAngle/Speed from player tank: 174.0/2.1500000953674316 |
| ||
hi Kauffy, i will look into this. Seriously i have never used a negarive speed factor but of course that should work. how is you friction value set? |
| ||
Ok, fixed. Will post an update soon. |
| ||
Fantastic! Thanks! Friction is set to 1. |
| ||
Hi, Mike-- I didn't see any new version posted anywhere. Has this change been committed or is this a simple change I should make to my own source? |
| ||
No. Wantrd to finish Box2d and waypoints first. But i will upload it like it is in a frw minutes so you have your fixes. Hope that it is ok for you. |
| ||
Hi Kauffy, I have uploaded a preview of Version 1.48 which includes the fixes for your problem and also all the new stuff. Waypoints and Box2D are in now way settled. If you want to use what is there, then it might be a subject of change. Mainly in how much it will be integrated into the ftEngine class and which event handler methods are called and in which class they are. Plus both classes need more methods. But you can see where it goes. Btw. for the Box2D stuff, you need this module: http://code.google.com/p/monkeybox2d/ Cheers Michael |
| ||
Hi folks, i would like to switch the documentation of fantomEngine to the Jungle Ide format. Means it would be compatible to Jungle Ide and i would ship generated docs with the module. Plus hosting them online, if you like to view them on your tablet. This way i could reduce or get rid of the wiki, which is a pain to maintain. What do you think? |