Home    LittleBigPlanet 2 - 3 - Vita - Karting    LittleBigPlanet 2    [LBP2] Tutorials
#1

Division of Signals

Archive: 4 posts


This tutorial will teach you how to divide any signal by a whole number (1, 2, 3, 4.... etc.)

Lets begin by looking at the SPEED SCALE setting for timers. Lets say you have a speed scale timer with max time of 1 second. You plug a 100% battery into the timer. It will take 1 second before the timer is full. However, if you plug a 50% battery into the timer it will take 2 second before the timer is full, similarly a 25% battery will take 4 seconds, 10% battery, 10 seconds etc.

Now that we know a little bit about the speed scale setting lets look at how LBP works.

We know that LBP renders 30 frames ever seconds, that means that everything updates 30 times a second, including logic components such as timers. 30 updates every second means 3 updates every 0.1 seconds; this means that a timer counting up to 0.1 seconds will be (1/3) full after 1 frame, (2/3) full after 2 and full on the 3rd frame.

If we have a timer trying to count to 0.1 seconds and we activate the timer reset once every second frame (by using a 2 port selector which cycles through itself endlessly) then the timer output will be 0 for one frame, then it will become (1/3) the next frame before being reset again to 0. However, if we have two timers which are reset in an alternating sequence and we connect their outputs with an OR gate we can hold a steady signal of (1/3) or 33.333333...%. Multiplying this signal by 3 simply by adding the signal to itself 3 times will give use a signal of 1 or 100%.

Now lets consider if these 0.1 second timers were set to speed scale and had a signal of 50%, rather than counting up to (1/3) every frame, they would only count to (1/6).

(1/6) x 3 = (1/2) or 50%

You might be asking why this is useful, we just get the same number out as the number we put in. Well, at the moment we are effectively dividing by 1 but what if the max time was 0.2 seconds? Lets break it down...

We plug in a 50% signal

In the first frame our timer counts (1/6) of 0.1 seconds

This time, because our MAX time is 0.2, (1/6) of 0.1 seconds will give a percentage of (1/12). Think about it, if it takes 6 frames to count to 0.1 seconds, it will take 12 frames to count to 0.2 seconds.

Multiplying this by 3:

(1/12) x 3 = (1/4) or 25%

Here we can see that we put in a signal of 50% and got 25% out, we divided the signal by 2. So setting the max time on the timer can change what you divide your signal by. A max time of 0.3 will divide your signal by 3, 0.4 will divide by 4 etc.

I'll add a few pictures at a later time.
2012-10-15 09:00:00

Author:
Seku
Posts: 65


Very nice clearly explained tutorial. Although i prefer the rotator and rotate sensor method because its dynamic allowing you to change the divide by amount in play mode2012-10-16 03:03:00

Author:
zippopot
Posts: 5


You might want to look at http://wiki.lbpcentral.com/Talk:Timer for a list of values where the timer will not be precise enough, making the division visibly wrong. If you need to divide by 10, you should divide by 90 and then multiply by 9, it is more precise.2012-10-18 17:42:00

Author:
Unknown User


Then, it only takes one frame to calculate ? Or more ? (Just to be sure)

Edit : I found what I looked for, thanks for this helpful tutorial
2013-01-24 11:18:00

Author:
Unknown User


LBPCentral Archive Statistics
Posts: 1077139    Threads: 69970    Members: 9661    Archive-Date: 2019-01-19

Datenschutz
Aus dem Archiv wurden alle persönlichen Daten wie Name, Anschrift, Email etc. - aber auch sämtliche Inhalte wie z.B. persönliche Nachrichten - entfernt.
Die Nutzung dieser Webseite erfolgt ohne Speicherung personenbezogener Daten. Es werden keinerlei Cookies, Logs, 3rd-Party-Plugins etc. verwendet.