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

Count objects in area

Archive: 20 posts


Working on a mini-game where players have to collect objects and bring them to their own area. They can also steal from other players areas. How could I, at the end of the timer, count the number of objects (that will have tags) in the players area. Or, even better could I somehow keep a live count going, that will go down when items are stolen. Is this even possible???2011-08-06 16:33:00

Author:
Unknown User


Place Tags on each object you want to count. Place a Microchip nearby and place some Tag Sensors on it, in a column. Set them all so that they detect the Tags within the area you wish to count. Then, place a Selector to the right of the Tag sensors, and connect them all up to the selector's inputs (make the selector longer if necessary).

You should then go from top to bottom, and set the Tag Sensors to require 1 tag, 2 tags, 3 tags ... and so on. The selector should then output out of the port number which matches the number of tags!

Hope this helps - I'd provide a diagram but I'm rubbish with Photoshop.
2011-08-06 16:46:00

Author:
Holguin86
Posts: 875


Is there anyway to do this without exclusive tag selectors. There may be 20+ objects, and the keep spawning, so there would have to be a lot of tag sensors.2011-08-06 17:57:00

Author:
Unknown User


The selector may not be the best choice. The problem is that once one tag is detected, that port of the selector will receive a signal and turn on its output, but when the next sensor detects two tags, the sensor for one tag will still be active. Both sensors will be trying to change the selector port but selectors operate on a first come first served basis so the second sensor will be ignored. You'll need something with AND gates or something--if one tag is detected AND two tags are not detected, then output one; if two tags are detected, disable output one; if two tags are detected AND three tags are not detected, output two. Yeah, it's a lot of wiring, but that's just how it is.

Unfortunately, I don't know of a way to count tags without using individual sensors for each numeric possibility. As I said, it's a lot of wiring, but it won't cost much in thermo so there's really nothing preventing you from doing it. I'm pretty sure I've tried setting a sensor to require a number of tags and then tried to receive an analog output from it and it didn't work. If a sensor is set to require 10 tags and there's only 9, it doesn't output a 90% signal; it outputs 0%. I may be remembering incorrectly so feel free to test it yourself, but I'm pretty sure that's how it is.
2011-08-06 23:11:00

Author:
Sehven
Posts: 2188


The selector may not be the best choice. The problem is that once one tag is detected, that port of the selector will receive a signal and turn on its output, but when the next sensor detects two tags, the sensor for one tag will still be active. Both sensors will be trying to change the selector port but selectors operate on a first come first served basis so the second sensor will be ignored. You'll need something with AND gates or something--if one tag is detected AND two tags are not detected, then output one; if two tags are detected, disable output one; if two tags are detected AND three tags are not detected, output two. Yeah, it's a lot of wiring, but that's just how it is.
.

Selectors work on the highest value. If one and two are selected at the same time, two becomes the active output.

What Holguin said is probably the best way. It's the method I am using on a level now with 60 objects at a time. It's a pain to set up, but not too bad. The upside is that it is dead accurate and keeps a live count going.

If someone knows a better way, I am all ears.
2011-08-06 23:26:00

Author:
tdarb
Posts: 689


The selector may not be the best choice. The problem is that once one tag is detected, that port of the selector will receive a signal and turn on its output, but when the next sensor detects two tags, the sensor for one tag will still be active. Both sensors will be trying to change the selector port but selectors operate on a first come first served basis so the second sensor will be ignored.

Fortunately this is not the case

Selectors always prioritize the Input with the highest numerical value. Say Input 2 and 5 is active at a time, then the Selector will activate Output 5. Therefore Holguins solution should be completely valid. With the current tech, I cannot think of any other solution as "simple" or effective as this one...

EDIT: What tdarb said
2011-08-06 23:35:00

Author:
Slaeden-Bob
Posts: 605


Ah, good to know. I guess I only tried it going the other way (selecting a lower number after the higher was selected), noticed it didn't work, and didn't test it any further. It's still a bit annoying that I can't set it to favor the most recent signal, but knowing what it likes, I can work with it instead of against it. And to think I've been over-engineering counter logic all this time 2011-08-07 03:36:00

Author:
Sehven
Posts: 2188


Fortunately this is not the case
Selectors always prioritize the Input with the highest numerical value. Say Input 2 and 5 is active at a time, then the Selector will activate Output 5. Therefore Holguins solution should be completely valid. With the current tech, I cannot think of any other solution as "simple" or effective as this one...


I can


Is there anyway to do this without exclusive tag selectors. There may be 20+ objects, and the keep spawning, so there would have to be a lot of tag sensors.

yeah i have a pretty simple (depending on how you are with logic) way, but it will require a chip on the objects instead of just a tag, but it should work with any number of objects without having to use heaps of different sensors wired into a selector

ok, put a chip on the object, and set up the logic as you see in this image (the black squares are all counters set to 1)
http://i0.lbp.me/img/ft/d20725d2d4e0cfa5b9157ac1f253ebdda6460df8.jpg
then set the sensor radius to the size of the player's collection area and have a corresponding tag in each collection area.
what this will do is pulse the blue tag when it enters a player's area then pulse the red tag when it leaves, you would then have a blue and red sensor in each area with the radius set to slightly larger than the objects radius, so it will only detect when an object is entering/leaving it's own area, then wire the blue sensor to count up one on your counter (you can use selectors, timers, counters or Feedback loops for a counter, depending on your needs) and wire the red sensor to count down one.

the only issue you may have with this setup is if 2 or more objects enter or leave a players area within 2 simulation frames it may only count one object, just depends on how likely you think this is to occur as to whether it will b an issue or not.
if it is you could look at buffering events (https://lbpcentral.lbp-hub.com/index.php?t=59607-How-to-buffer-events-(and-use-it-with-a-counter)), but that may make things over-complicated especially as the is nothing really wrong with the multi sensor method
2011-08-07 06:09:00

Author:
evret
Posts: 612


Increment a counter by 1 each time you detect a object.

lol
2011-08-07 06:15:00

Author:
Ayneh
Posts: 2454


he said the object should only be part of the count while it remains in the area, for that to work you would need to turn off the tag after it enters so the next could be counted, but you would still need to be able to count down as it leaves the area2011-08-07 06:41:00

Author:
evret
Posts: 612


Increment a counter by 1 each time you detect a object.

lol

Except you can't output a value based on the current count... the only outputs are "1(or 100%)" when full, else "0".
2011-08-07 06:41:00

Author:
xero
Posts: 2419


Well, depending how things are set up it would work just fine. If things enter and exit though the same space a couple of impact sensors mounted on bilateral holo gates would be able to detect a tagged object entering or exiting an area depending what order they were activated in. I dunno.2011-08-07 07:10:00

Author:
Ayneh
Posts: 2454


Except you can't output a value based on the current count... the only outputs are "1(or 100%)" when full, else "0".

You can with a positional sequencer.


evret, The green sensor would stay active as long as a tag is in range. It wouldn't count anything after that until all tags leave and it decrements back to 0.


For keeping a live count, counting tags with sensors set to various numbers really is the most reliable. It takes longer to set up, but it handles all the variables.

EDIT-looking at evret's post again, that would work except if two objects cross at the same time. It's still not very efficient though. I think 20 tags and 20 sensors is a better use of thermo.
2011-08-07 07:13:00

Author:
tdarb
Posts: 689


Well, depending how things are set up it would work just fine. If things enter and exit though the same space a couple of impact sensors mounted on bilateral holo gates would be able to detect a tagged object entering or exiting an area depending what order they were activated in. I dunno.
that would need logic like mine on each object too, just using impact on exterior of the area would have alot of issues with 2 or more coming through close together.
you could change the sensor on the object to impact (require tag) and have one large bit of holo covering the whole of the players area with a tag on it and it would work the same. but if your area is circular than the tag sensor method would be easier


You can with a positional sequencer.
EDIT-looking at evret's post again, that would work except if two objects cross at the same time. It's still not very efficient though. I think 20 tags and 20 sensors is a better use of thermo.
yeah i already believe that way is more reliable, however mmm11105 asked if there was a way to do it without being limited to the number of sensors you had wired into the selector
i also posted a link to a thread that shows a way to overcome the issue of 2 or more crossing at the same time
2011-08-07 07:18:00

Author:
evret
Posts: 612


I think I'll just go with the selector method, thanks to everyone for the answers2011-08-07 15:18:00

Author:
Unknown User


You can with a positional sequencer.
Oh believe me, I know. But that isn't the best option for what the OP needs done. Increasing and decreasing values becomes too tedious using a positional sequencer. Also...


Increment a counter by 1 each time you detect a object.
...We're not talking about sequencers... we're talking about a counter.
2011-08-07 21:40:00

Author:
xero
Posts: 2419


Oh believe me, I know. But that isn't the best option for what the OP needs done. Increasing and decreasing values becomes too tedious using a positional sequencer. Also...


...We're not talking about sequencers... we're talking about a counter.

What I was saying is that if you attach a counter to a positional sequencer, you can then use that position to display a value. Increasing and decreasing values on the sequencer would be as simple as adding to, or subtracting from, the counter once it is set up.

Counters do put out a digital signal, but they also put out an analog signal representing the percentage they are full. Your statement that they only output digitally (100% or 0%) is incorrect.

You still run into the issue of counting simultaneous increments/decrements.
2011-08-07 22:17:00

Author:
tdarb
Posts: 689


What I was saying is that if you attach a counter to a positional sequencer, you can then use that position to display a value. Increasing and decreasing values on the sequencer would be as simple as adding to, or subtracting from, the counter once it is set up.

You're absolutely correct, I had completely forgotten about that. But this also has another flaw; say you had a system where you wanted to count a constantly increasing number of objects. Using your system (a counter & sequencer) only allows for a static number of objects to be counted. The maximum value of a counter is 100, limiting the maximum possible number of objects to be counted at 100. If you had objects constantly emitting and wanted to keep track of them, you'd hit a wall once you reached that cap.
2011-08-07 22:47:00

Author:
xero
Posts: 2419


To be fair, you'd hit that cap with the selector method too, as the maximum amount of ports allowed on a selector is 100, and I believe the "Number of Tags Required" tweak on the tag sensor only goes up to 100 too .2011-08-08 08:52:00

Author:
Holguin86
Posts: 875


To be fair, you'd hit that cap with the selector method too, as the maximum amount of ports allowed on a selector is 100, and I believe the "Number of Tags Required" tweak on the tag sensor only goes up to 100 too .

That's why you use a 7-segment display-type counting system instead; it has absolutely no limit.
2011-08-08 22:43:00

Author:
xero
Posts: 2419


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.