Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Shaking object with movement - I don't want this!

Author
Message
Davey B
21
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 25th Aug 2010 20:23
Hello again,

Right my problem is that as my object moves, it gradually develops a shake, which gets worse over time. If movement stops the shake stops. When I start moving again the object shakes again with the same intensity it was last at. Any idea what the problem is?

Nothing fancy used to control the player just:


I've seen threads about this:
http://forum.thegamecreators.com/?m=forum_view&t=58013&b=1
http://forum.thegamecreators.com/?m=forum_view&t=58013&b=1

I dont understand their solution here, and moving the origin seems kinda strange to me. Besides I'm designing a game in space so I cant really remain in the confines of a small usable coordinate range. Any one else had this / is my code at fault? Is it a bug within DBPRO?

Cheers
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Aug 2010 21:57
Quote: "as my object moves, it gradually develops a shake, which gets worse over time"

You may have fallen foul of floating point limitations.

Firstly, floating point numbers take up 4 bytes of memory. 4 Bytes of memory can hold just over 4 billion different combinations of bits. However, floats can hold numbers from as small as 1x10^-38, up to 3.4x10^38 - a much larger range than can be stored in 4 bytes.

It does this by using a logarithmic scale - you always have around 7 significant digits of accuracy, and the decimal point moves around.

For example:
1.0000001 is probably OK, range-wise, but 1.0000000001 won't be.
1000001 is probably OK too, but 1000000001 won't be.

Basically, as the numbers get larger, the minimum 'steps' between representations of those numbers also become larger.

Also something to take into account is that in the same way as you can't represent 1/3 in decimal, there are numbers that can't be represented fully using floating point - 1/10 can't for example (although I believe DBPro will show you the correct result, it's 'cheating' slightly by dropping precision and rounding).

Now, how does that aid you? It doesn't. But this might...

One way to deal with this is to determine the point where the numbers become 'too large' for your program, and then reset everything back to the origin.

For example, your camera is at 10000.0, 0.0, 0.0 and what you are aiming for is at 10500.00, 0.0, 0.0 - you reset your camera back to 0.0, 0.0, 0.0, and then move your target by a like amount to 500.0, 0.0, 0.0 and do the same for all other assets in the game arena.

Davey B
21
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 25th Aug 2010 23:27
Cheers IanM, that explanation was perfect. I figured out how to achieve some way of fixing the origin and made this cheap and dirty fix for now



Thanks again!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Aug 2010 01:10
That will work fine if you only travel in directions where the x/y/z coordinates increase in the positive direction.

Change this kind of thing:


To something like this:


That should do the job in any direction.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet

Login to post a reply

Server time is: 2026-07-23 09:15:46
Your offset time is: 2026-07-23 09:15:46