Home    LittleBigPlanet 1 - PSP - Tearaway -Run Sackboy Run    LittleBigPlanet 1    [LBP1] Tutorials [Archive]
#1

How to make rectangular sensor areas!

Archive: 51 posts


Most of you will know that the "Camera Tool" has got a rectangular activation area, as opposed to proximity and mag switches which do only feature a circular area.

A while ago, I thought it would be quite useful at times if we had the option to set a rectangular radius for all our switches. Well, I didn't give it much thought at that time.

It was tonight when I suddenly needed said feature and started playing around with the proximity switch. And I did indeed find a most thermo-friendly and simple solution. Some logic- and tech-interested people (like me) here on LBPC will probably already have figured this out by now, but I'll post this tutorial for all who might be interested in this technique. It's really not much of a big deal. I've done some screenshots, but I don't think I'm even going to need them here.

Ok, so in order to use this, you'll have to understand the basic concept: What we want to do is creating a rectangular "area". This is not possible using only one single proximity switch. So, let's think of it: How could we create a rectangular shape by ourselves? the closest thing to a rectangle you can get is a quarter circle. So, how do we get a rectangle? The following sketch might give you a clue:



http://www.abload.de/img/demicircleg2d8.png

See the astounding simplicity? Basically, all you have to do is setting up 2 proximity switches, each angled at 45 degree and with a radius of 90 degree (one turned by 180 degree), so that their right-angled sides form a rectangle. Just change the positions of the two switches (but make sure that each switch is positioned within the activation area of the other one) in order to create every possible rectangular shape.

Next step: Create an AND gate (http://www.lbpcentral.com/forums/blog.php?b=411) and link your two proximity switches up to that gate (so that the output only gets activated when both of them are active at the same time, which means that a player has to stand in the rectangular area). You're done! Simple, wasn't it?

This same technique does also apply to magnetic switches. All you need are two switches and an AND gate.

Of course, using the same basic idea - connecting multiple switches with different activation areas using any logic system - you can create nearly every shape you could imagine. Oval, hexagon, L-shape - anything is possible. Just use your imagination and a fitting set of AND, OR and whatever else you may need.

Update 11.10.09

Actually, you can create any desired shape using this technique. Here's a few simple guidelines as for which logic gate fits which needs:

Note: I always use a set of 2 sensors for the examples below. "N" stands for normal state, "I" stands for inverted state. [NI], for example, means that the left sensor (represented by the left circle) has to be normal whereas the right sensor has to be inverted.

Intersection: AND Gate [NN]
(Multiplayer: Require All)

http://www.abload.de/img/schnittmengen6eg.png

Set Union: OR Gate [NN]
(Multiplayer: NO Require All)

http://www.abload.de/img/vereinigungsmengew6a6.png

Difference Quantity: AND Gate [NI]
(Multiplayer: Normal: Require All, Inverted: NO Require All)

http://www.abload.de/img/differenzmengex6yn.png

Complementary Set: XOR Gate [NN]
(Multiplayer: not reliable)

http://www.abload.de/img/komplementrmenge1691.png

Of course, you can combine any desired amount of sensors (at any angles) and as many gates as you want. This allows you to create pretty much any shape you could ever dream of.


Hope this helped
2009-10-08 00:00:00

Author:
Treas
Posts: 223


Tho technically you only need one of them as both switches cover that area...2009-10-08 00:25:00

Author:
Silverleon
Posts: 6707


I don't quite get your point. You mean that you only need one sensor switch to form a perfect rectangular detection area? If so, how would you do this?2009-10-08 00:36:00

Author:
Treas
Posts: 223


Thats a pretty smart idea for making a very defined sensor area. I'm not entirely sure where i would need it though... could i get an example?2009-10-08 00:43:00

Author:
Burnvictim42
Posts: 3322


Which room is sackboy in?2009-10-08 00:46:00

Author:
rtm223
Posts: 6497


It's all so simple now! Thanks for this!2009-10-08 00:52:00

Author:
adlingtont
Posts: 321


Did I forget to mention that you can change position, length and width of the rectangle in real-time by just attaching the sensors to movable surfaces?

You could, for example, create a survival challenge where the player does always have to fly (or swim, yay!) within the boundaries of a certain frame of laser beams. This would require exact detection lines, as a player wouldn't want to get killed just because he got near a laser, not even touching it.

Just a quick idea though, and I'm sure there's lots of uses for it.
2009-10-08 00:53:00

Author:
Treas
Posts: 223


A note on "exact detection lines":

They aren't. On a small scale the sensors generally are accurate enough, but on a larger scale both the curved and straight edges aren't exactly where you think they are.

It's hysteresis, for those who are familiar with the term. If not it's probably just easier to make sure you test it thoroughly.
2009-10-08 00:59:00

Author:
rtm223
Posts: 6497


Simple and effective, I like it.

I might find a use for a system like this in the future, so I'll be sure to keep it in mind.
2009-10-08 01:02:00

Author:
Gilgamesh
Posts: 2536


It's hysteresis, for those who are familiar with the term.

Jup. Did some intense testing on the activation radius and it definitely is hysteresis. But the inner and outer limits are quite close together. Lies around 1-2.5, to put it in LBP measurements. So, the maximum divergence is one small grid block. Plus, sackboy's head doesn't count towards collision or sensor area detection.

I did some tests and found that my rectangular areas deliver more precise results in spite of hysteresis. Plus, it is especially useful if you want a "dynamic" range (described in my last posting).
2009-10-08 10:26:00

Author:
Treas
Posts: 223


I thought that on large scale sensor areas it was massive? Either that or there is a huge discrepancy between the graphics for the detection zone and the actual detection zone. BTW I'm not saying that the rectangular areas are less precise, it's the fact that the sensors themselves are imprecise and don't trust those graphics 2009-10-08 10:41:00

Author:
rtm223
Posts: 6497


I know. The "blurry", fading outline of the sensor area itself already tells us about the massive lack of precision. The discrepancy does indeed get bigger, but my no means proportional to the size of your detection area. I haven't yet figured out any exact measurement, seems to be quite a piece of difficult code behind that. Still, it's precise enough for most tasks, so I'm not too frustrated about them right now.2009-10-08 14:30:00

Author:
Treas
Posts: 223


That s a great idea once i saw the diagram i figured it out straight away its pretty simplae actually, This idea could go further if you need it even more precise with three or four sensor switches but its not quite needed.2009-10-08 14:35:00

Author:
robotiod
Posts: 2662


That looks awesome, if i build another level, i'm gona put this in it somewhere, thanks 2009-10-08 14:37:00

Author:
springs86
Posts: 785


Great post! I never imagined having to use a quad shaped sensor area, but you make perfect sense.

This would also be great on doors and springboards since the spread is much more even and predictable.
2009-10-08 14:42:00

Author:
Foofles
Posts: 2278


If you think cleverly about it you could make a tine exact point were sackboy must be by using 2 sensors with angle set to one so it would be really presice2009-10-08 14:50:00

Author:
robotiod
Posts: 2662


I was just thinking about this last night actually so its weird to see you have posted it here today Although the solution I came up with was using 4 switches, one on each corner so yours is twice as elegant a solution. What I was thinking of using this for is having an exact positioning system for players in the air (or water). If you were to build a grid of these sensors then you can pinpoint the player on the screen. knowing that of course can lead to some really interesting possiblilities.2009-10-08 14:51:00

Author:
wexfordian
Posts: 1904


I was just thinking about this last night actually so its weird to see you have posted it here today Although the solution I came up with was using 4 switches, one on each corner so yours is twice as elegant a solution. What I was thinking of using this for is having an exact positioning system for players in the air (or water). If you were to build a grid of these sensors then you can pinpoint the player on the screen. knowing that of course can lead to some really interesting possiblilities.

What your getting into here is like big brother, The level knowing exactly were you are at any one time, make a tracking system that follows sackboy anywere and you have pretty much full control of there path. Now how this would be helpful would be well above a normal creators level but imagine fully interactable character and stuff like that.
2009-10-08 14:53:00

Author:
robotiod
Posts: 2662


What your getting into here is like big brother, The level knowing exactly were you are at any one time, make a tracking system that follows sackboy anywere and you have pretty much full control of there path. Now how this would be helpful would be well above a normal creators level but imagine fully interactable character and stuff like that.

Now were thinking along the same lines
2009-10-08 14:56:00

Author:
wexfordian
Posts: 1904


If you think cleverly about it you could make a tine exact point were sackboy must be by using 2 sensors with angle set to one so it would be really presice

Forget the "Angle set to one". As rtm223 has already pointed out, the positioning of the actual sensor area doesn't exactly match the displayed, blurry outlines: The area of effect changes everytime it is triggered or untriggered. It's like chewing gum, to put it simple: When you move out of a sensor area, it will "stretch out" a little bit and follow you, expanding a little. When you step in again, it will "stretch back" with your movement. This effect isn't really noticeable when you move fast, but experiment with small mag keys and switches and you'll see it.

This does also apply to tight-angled mag switches: Angles below 10 degree tend to get buggy. Sometimes, they activate way before the given object enters the area, and at other times, you can drop a mag key right through the detection area and the switch wouldn't even activate.

Be careful with 1 degree angles
2009-10-08 15:33:00

Author:
Treas
Posts: 223


I don't think it has been mentioned yet, but deftmute came up with a great way to give precise angles to the placement of sensor switches. He considered it for 90 degrees (perfectly sideways), but it can be extended to make sure your sensor switches are at exactly 45 degrees when you place them (allowing for a perfect square).

Get out the right triangle shape and drop your sensor switch on it. Turn off grid mode and butt the long side of the right triangle up against a flat horizontal or vertical surface until you get a clean 45 degree angle for the sensor switch in the desired direction. Then, copy the sensor switch (do not detach it - it will automatically realign to default angle), and place it as desired. Boom! Perfect 45 degree angle placement.

-----

Also, I have been using something similar to this to achieve more accurate searchlight player sensing that might be of use. You know how when using a searchlight, trying to tweak the angle and distance is quite a hassle? What I do is tweak the the trigger area for a searchlight to be a huge circle that covers way more area than necessary. Then I put a sensor switch in the area where I want the player to activate the "Logikz". Wire the searchlight and the sensor switch through an AND gate and you are finished. This allows more precise, layer specific sensor switch activation.

This has come in handy several times now.

2009-10-08 16:00:00

Author:
comphermc
Posts: 5338


Also, I have been using something similar to this to achieve more accurate searchlight player sensing that might be of use. You know how when using a searchlight, trying to tweak the angle and distance is quite a hassle? What I do is tweak the the trigger area for a searchlight to be a huge circle that covers way more area than necessary. Then I put a sensor switch in the area where I want the player to activate the "Logikz". Wire the searchlight and the sensor switch through an AND gate and you are finished. This allows more precise, layer specific sensor switch activation.

That's a nice solution but I see one problem:
http://dl.getdropbox.com/u/1267706/switchError.jpg
So if player 1 is in the layer of the spotlight and player 2 is in radius of the prox switch, the logic will be triggered even if player is not in the desired area. This makes things trigger too early.
2009-10-08 21:06:00

Author:
ZramuliZ
Posts: 55


Get out the equilateral triangle shape and drop your sensor switch on it. Turn on grid mode and rotate the equilateral triangle until you get a clean 45 degree angle for the sensor switch in the desired direction. Then, copy the sensor switch (do not detach it - it will automatically realign to default angle), and place it as desired. Boom! Perfect 45 degree angle placement.


Perfect, within a tolerance of 15 degrees What you really want to do is put it on a right-angled triangle and then with grid mode OFF, butt it up against the floor or a vertical wall. That is how you get 45 degree angles. They stopped teaching sums in your maths lectures comphy?


@Zramuliz - this is true, and it would also affect the method in the OP. However, Wex's solution does not suffer from this. It depends how 2 player safe you need to be vs thermo considerations.

Of course you can make a "require all" box using treas's solution, by setting both proxes to require all.
2009-10-08 21:38:00

Author:
rtm223
Posts: 6497


It's an excellent idea, but just to bring some useless bull on the table, it's impossible to have a rectangle. Why? It's 2 quarters of a circle. This only creates squares

.
2009-10-08 23:09:00

Author:
RangerZero
Posts: 3901


Perfect, within a tolerance of 15 degrees What you really want to do is put it on a right-angled triangle and then with grid mode OFF, butt it up against the floor or a vertical wall. That is how you get 45 degree angles. They stopped teaching sums in your maths lectures comphy?

Lol, I guess so. I will edit that now.


That's a nice solution but I see one problem:

[Picture]

So if player 1 is in the layer of the spotlight and player 2 is in radius of the prox switch, the logic will be triggered even if player is not in the desired area. This makes things trigger too early.

Require All? (on both of them) I have used this in a level that works for multiplayer, so I know it works.
2009-10-08 23:19:00

Author:
comphermc
Posts: 5338


It's an excellent idea, but just to bring some useless bull on the table, it's impossible to have a rectangle. Why? It's 2 quarters of a circle. This only creates squares

.


You may wanna go back and take a closer look at the OP there buddy
2009-10-08 23:32:00

Author:
rtm223
Posts: 6497


You may wanna go back and take a closer look at the OP there buddy

Ok, I missed the "AND switch" part. This indeed make so the area not in the rectangle will do nothing.

.
2009-10-09 00:42:00

Author:
RangerZero
Posts: 3901


Require all! That's it! Why I didn't think about it. *goes to fix own levels with this new info* 2009-10-09 08:38:00

Author:
ZramuliZ
Posts: 55


wow thats awesome...2009-10-09 18:10:00

Author:
Kern
Posts: 5078


Actually, you can create any desired shape using this technique. Here's a few simple guidelines as for which logic gate fits which needs:

Note: I always use a set of 2 sensors for the examples below. "N" stands for normal state, "I" stands for inverted state. [NI], for example, means that the left sensor (represented by the left circle) has to be normal whereas the right sensor has to be inverted.

Intersection: AND Gate [NN]

http://www.abload.de/img/schnittmengen6eg.png

Set Union: OR Gate [NN]

http://www.abload.de/img/vereinigungsmengew6a6.png

Difference Quantity: AND Gate [NI]

http://www.abload.de/img/differenzmengex6yn.png

Complementary Set: XOR Gate [NN]

http://www.abload.de/img/komplementrmenge1691.png

Of course, you can combine any desired amount of sensors (at any angles) and as many gates as you want. This allows you to create pretty much any shape you could ever dream of.
2009-10-10 10:34:00

Author:
Treas
Posts: 223


Wow thanks for this! U just gave me a great idea for my science lab survival challenge Ive been workin on. I cant wait to start messin with this concept. Truly helpful post. 2009-10-10 20:48:00

Author:
tru3_skitz0
Posts: 114


I added this to my Helpful Threads and Links thread (https://lbpcentral.lbp-hub.com/index.php?t=t=17342)! Good job!2009-10-10 22:11:00

Author:
Sunrise_Moon
Posts: 469


Thanks for all your feedback and inputs. And thanks to Sunrise_Moon for adding it to your thread!

I really enjoyed the vivid discussion which unfolded in this thread. Keep the good (tech and logic) vibes coming!

I've added the short set theory overview to the tutorial to keep things clean and tidy.
2009-10-11 15:38:00

Author:
Treas
Posts: 223


You might want to add a section on the multiplayer limitations of these techniques. For example:

AND: Only works sensibly / reliably as a "require all"
OR: Only works sensibly / reliably as NOT "require all"
Difference Quantity: Won't work in multiplayer.
XOR: Won't work in multiplayer.

By won't work, I mean that the behaviour does not accurately match a "any player in the area" or "all players in the area".
2009-10-12 13:06:00

Author:
rtm223
Posts: 6497


Thanks for the addendum, rtm! I'll add that to the tutorial.2009-10-12 13:12:00

Author:
Treas
Posts: 223


Difference Quantity: Won't work in multiplayer.
XOR: Won't work in multiplayer.

Good point, but the last two aren't true. You can say all players are in area A (require all) AND none are in area B (require any, inverted) for the difference (reliable only as require all). For XOR, you are right it won't work straight up, but there are some possibilities, depending on what you want (who wants such a weird sensor area anyway ).

Let's just say you have to be extra mindful of multiplayer. As always.
2009-10-13 13:46:00

Author:
Rogar
Posts: 2284


Very true, I missed that combination for difference quantity. Good spot2009-10-13 14:26:00

Author:
rtm223
Posts: 6497


Nice I'm in a bit of a hurry at the moment, gonna update the tutorial as soon as I find some spare time.2009-10-13 14:34:00

Author:
Treas
Posts: 223


Really smart, I was developing a concept just like this one, but it used 4 sensor switches. I noticed the blurry outline once when creating, and you had to go all the way past to the blur to activate the sensor switch, and all the way out to de-activate it, which generally creates 2 separate lines, one for entry and one for exit.2009-10-15 00:52:00

Author:
srgt_poptart
Posts: 425


Really smart, I was developing a concept just like this one, but it used 4 sensor switches. I noticed the blurry outline once when creating, and you had to go all the way past to the blur to activate the sensor switch, and all the way out to de-activate it, which generally creates 2 separate lines, one for entry and one for exit.

Yup, I believe rtm223 called it hysteresis. He's too smart sometimes. That's exactly what is happening, and it's pretty frustrating at times...
2009-10-15 00:56:00

Author:
comphermc
Posts: 5338


Hysteresis can (and is even supposed to) be a good thing! It's a calculating method which should get rid of any kind of zig-zag movement around a certain limit. However, in LBP, it does clearly not fulfill its purpose. I haven't yet observed a single instance where it helped to get any device working. If you put a sensor switch (rotation 90 degree, angle radius 180 degree) on a wobble bolt and set it to directional, hysteresis should (or could, at least) achieve that the wobble bolt would not panick and have a seizure, but to lock on any sackboy and remain still. That's the basic purpose of hysteresis.

I think though that, if Mm decided to use hysteresis, they should at least give us the option of tweaking the value.
2009-10-15 17:56:00

Author:
Treas
Posts: 223


Thats really good, but wouldn't it be a bit hard to see the actual rectangle, as you can only tweak one switch at a time? You could in theory just use another controller, but that might be a bit awkward.2009-10-18 18:27:00

Author:
srgt_poptart
Posts: 425


I used hysteresis in a level, as it was a component in a Player Tracking Device. (PTD)
It helped make it so that the piston would not move back and forth violently, like you said about the wobble bolt.
2009-10-18 18:32:00

Author:
srgt_poptart
Posts: 425


Thats really good, but wouldn't it be a bit hard to see the actual rectangle, as you can only tweak one switch at a time? You could in theory just use another controller, but that might be a bit awkward.

Well, not really. I mean, imagining two straight lines going out from a visible source (the prox switch) isn't that hard. Plus, you can always work with stripes of material to mark the borderlines while you work on it. And I think the advantages (free-form dynamic rectangles etc) do clearly outweigh that issue.


I used hysteresis in a level, as it was a component in a Player Tracking Device. (PTD)
It helped make it so that the piston would not move back and forth violently, like you said about the wobble bolt.

I guess you've built some hysteresis logic yourself? I didn't yet get the hysteresis "add-on" on prox and mag switches to work in any useful way.
2009-10-19 06:11:00

Author:
Treas
Posts: 223


Hysteresis can (and is even supposed to) be a good thing! It's a calculating method which should get rid of any kind of zig-zag movement around a certain limit. However, in LBP, it does clearly not fulfill its purpose. I haven't yet observed a single instance where it helped to get any device working. If you put a sensor switch (rotation 90 degree, angle radius 180 degree) on a wobble bolt and set it to directional, hysteresis should (or could, at least) achieve that the wobble bolt would not panick and have a seizure, but to lock on any sackboy and remain still. That's the basic purpose of hysteresis.

I think though that, if Mm decided to use hysteresis, they should at least give us the option of tweaking the value.

I think the problem here is that while the sensors have hysteresis, the wobble bolt on direction can only go one way or the other, there's no input to stay still. So you have to work around that, maybe with a threeway switch?
2009-10-19 13:54:00

Author:
Rogar
Posts: 2284


I think the problem here is that while the sensors have hysteresis, the wobble bolt on direction can only go one way or the other, there's no input to stay still. So you have to work around that, maybe with a threeway switch?

It depends on the effect you're after. Treas didn't give a lot of details. If you want something like an object on a wobble bolt which points to the player - then I've had success using the setup you've described - one sensor switch pointing to each side, which pull on an offscreen 3-way switch. You can see the effect with the sackboy-tracking lights that appear in the first 10 seconds of this youtube vid, :

YouTube - LittleBigPlanet level Creete, a high-speed race

It still goes into zigzag mode sometimes (like the pink light does) but it's not the hysteresis thing as much as the inaccuracy/time delay of the 3-way switch mechanism. The lights appear later on in the level too, where the "zigzag" effect is less noticable because the player's moving faster.

Also, as Treas said, the hysteresis effect doesn't help this mechanism either :d
2009-10-19 14:07:00

Author:
Argon Vile
Posts: 28


I think the problem here is that while the sensors have hysteresis, the wobble bolt on direction can only go one way or the other, there's no input to stay still. So you have to work around that, maybe with a threeway switch?

You're completely right about that, and I do actually use three-way switches for all such contraptions. Still, I'm really curious if anyone found an actual use for the built-in hysteresis...
2009-10-19 15:59:00

Author:
Treas
Posts: 223


I didn't use the built-in hysteresis, as it is much too small to be any use at all. I just put too sensor switches bottom to bottom, but instead of making the angle 180 degrees, I made it 160, so there is a space in the middle.2009-10-20 00:41:00

Author:
srgt_poptart
Posts: 425


You're completely right about that, and I do actually use three-way switches for all such contraptions. Still, I'm really curious if anyone found an actual use for the built-in hysteresis...

I've got one. A slightly lower thermo version of my dissolve free p-switch. You tweak it so that the starting point of the mag key is in the hystersis zone, then you activate the piston. At this point the key acticates, but it can never deactivate, because it will never move OUT of the hysteresis zone. TBH though, that's contrived and I don't trust the reliability of it.

Realistically, hysteresis is great for rounding errros / fluctuations and such. You will never notice these things, but hysteresis isn't there to be noticed, or to add explicit features - it's one of those things you notice because of its absence. You don't notice the hysteresis in your thermostat, but you would notice it not being there when your boiler breaks, for instance
2009-10-20 00:55:00

Author:
rtm223
Posts: 6497


I suppose so. It's one of the things we take for granted in LBP.2009-10-20 02:27:00

Author:
srgt_poptart
Posts: 425


awesome I am in the process of making a music level using mag keys but some don't play because of the circular area of the activation area as it where this really helped thanks a lot!2009-10-22 08:52:00

Author:
lbpholic
Posts: 1304


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.