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

Score sensor

Archive: 3 posts


I have discovered that my RTS game wont work as i want to only because of a feature I think is missing. My new level is a multiplayer game and i want the score sensor to feel each players score, not just the highest score. I have tried doing that by setting the score sensor's colour to the player colour but it still does not work. It causes problems when buying units.

Am I doing something wrong?
2011-03-31 10:21:00

Author:
Willman4
Posts: 170


Hello, Willman!

Up front, I'd like to reassure you that you're not doing anything wrong. You're actually tackling a major shortcoming of the game system. It is something that can only be addressed by an alteration that Media Molecule would produce, or a great deal of innovation on your part.

The score sensor is simply not built to measure anything but a minimum score at this time. It has no way of distinguishing who has that score ......... except through mathematics.

I feel I got really close to beating this problem. Here's what I did, along with the pitfall that I was not able to overcome:

The Goal

Given that there are between 2-4 players, and we suspect someone has reached a score threshhold (first to 500 points, for example), we want to detect which player achieved that threshhold.

The Tools

* You can ask the game if anyone has reached an arbitrary score, e.g. "Does Anyone Have 500 points?", and get a yes/no answer.
* You can add or subtract a significantly large (though not boundless) quantity of points from any player you want, with one exception:
* You cannot give any player less than 0 points.

A "Quick" (HA!) Note About Modifying Points

The Score Giver object is not obvious in its operation.
It will give an assigned (fixed) amount of points to a player when an on-signal is fed into it, HOWEVER,
The on-signal must carry a player "flavor".
It can be difficult to wrap one's head around player flavors. Basically, a tool/object will become 'drenched' in a player's flavor whenever that tool receives a player signal, or produces a signal that answers a question about a player. The tools that produce player-flavored signals are:

- Controlinator: All the outputs to a controlinator are drenched in the flavor of the player sitting in it. (Kinda begs the question.. When was the last time you washed your sackfolk?)
- Player Sensor: Produces an on-signal with the flavor of the (closest?) player that moved into range.

So, like the tutorial shows, if you have a Player Sensor hooked up to a Score Giver, and a player walks up to it, they get some points.
Less obviously, if a player pushes the X button of a controlinator, whose X button is hooked up to a Score Giver, that player gets some points.
Even less obviously, if a player pushes a button that is straight hooked up to a Score Giver, NO ONE gets points. (No player flavor is transmitted through button contact.)

Even less, less obviously, a Selector whose first input is a button, and whose second input is a player sensor will output player flavor when the player approaches the sensor. Here's where it gets crazy. This same selector will not output player flavor if the Player Sensor is never activated, BUT ... it becomes drenched in the player's flavor for all time afterwards, if the Player Sensor is activated even once.

A selector with up to 4 player flavors input into it will output the flavor that has the highest active input number. So if player A's standing next to Player Sensor attached to Selector Input 2, and Player B's standing next to Player Sensor attached to Selector Input 3, the selector's output is flavored to Player B.

An AND gate, OR gate, NOT gate, etc., combining player-flavored signals and flavorless signals will output a flavored signal. I haven't seen yet, which flavor will be poduced frmo an AND gate with two player flavors input into it. Based on my history with Logic, I'd guess it outputs Input #1.

Got all that? 'Cause now we're finally ready to tackle...

The Solution

You will need: To determine a practical limit (known as a "ceiling") for ALL individual player scores.
That is, think: "I have 10,000 worth of Score Bubbles in my level, OR a player could never practically gain 10,000 points under normal playing conditions."

Pseudo-code for what you want to do looks like this:
(Note: Creators don't actually program code in LBP2. However, pseudocode is a creation tool that applies to all schools of game design.)

>set COUNTER to min value 0,
max value PLAYER COUNT
>set SELECTOR INPUT to any player signal
:begin loop PLAYERS
>add score CEILING to SELECTOR INPUT (player signal)
>ask Score Sensor: anyone with minimum score [CEILING plus THRESHOLD (precalculated)]?
if yes: do thing, set BREAK LOOP toggle
>subtract score CEILING from SELECTOR INPUT (player signal)
>cycle SELECTOR INPUT to next input number (next player signal), add 1 to COUNTER

:end loop PLAYERS: if not COUNTER MAX, or BREAK LOOP, goto PLAYERS beginning (loop again)

And that, in a nutshell, is how you beat the Score Sensor system.

Wait, Wait, Wait ... Didn't You Say You Actually Failed to Do This?

Ah, yes ... Sad but true story.

I'm sure I was overlooking something, but what happened in my case is that when multiple players' scores were increasing very rapidly, my loop went crazy, adding the ceiling onto everybody ... or worse, it would add the CEILING twice to one player, making it so that the THRESHOLD condition was always true. It also seemed like the addition of two score amounts in a brief period would "overlap" some of the gain (e.g.: 500 + 500 = 980?!!?), making it so that no-one ever reached THRESHOLD.

Hopefully, that will never happen to you.

One may also wish to note that while you're doing all this looping, and test-adding, test-subtracting, the players' scores will leapfrog each other frequently, causing that PWEE-ooo noise, and a good bit of animation happening in the top-left corner. A necessary evil, I'm sorry to say.

Oh, also, there are no scores in Create mode, so you'll never know if you truly got the thing right until you Play The Level. It can be annoying to wait through that loading screen over and over while you bang out the kinks in the loop.
2011-03-31 19:26:00

Author:
The Manx Turtle
Posts: 50


First of all, thanks very much. This helped a lot.

When I discovered this little problem, I started to think. Is there a way I can do this without using the score sensor? I can really understand if you don't get this because my level is very complex and you don't know how it is built. Anyway, I think I have solved this problem by using counters and make a sort of storage for points. I need to know if the storage is empty so the only way to do that is using a lot of counters set to 1. Then there is a full mode and an empty mode, nothing in between. Due to that i had to let every counter be equal to 100 points. There also need to be a limit so i set it to 3000. Of course, the storage can hold a lot more but the thermometer doesn't like it.

Hope you want to play it when I am done with it because it is not a crappy RTS like every level that are out there today (all I've played). The problem with all RTS games is that units slam into each other, get stuck into walls and all selected units wants to go to the same place. I think I have fixed most of those problems but of course there is still room for improves.

Sorry if my english is bad. Thanks again.
2011-03-31 20:48:00

Author:
Willman4
Posts: 170


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.