Hiya. I am Kris and today I am going to let you in on a simple technique to keep a moving, controlled object from going outside an invisible bounding box.
There are techniques out there that give mixed results. You may have tried a few yourself, varying from using followers that make the object flee from the sides to removing user control and bouncing the object back into the arena. No such thing here, though. I set out to make this one work as smoothly as possible; as if you are pushing up against an invisible wall and without losing control of your object.
Start off with something like this: a block of holographic material with a controlinator on it; as you can see here, the left/right and top/down output of the left joystick are hooked to an advanced mover (don't forget to set its deceleration to 100%. Thanks Deafmanwalking). If you'd hop into the controlinator right now, you can freely move block around. We want to go and limit that to an invisible bounding box.
Whatever movement you make with the joystick, it can always be split up into a horizontal vector and a vertical vector. For example, you move the block into a north-west diagonal direction; this means there is a negative movement on the X-axis combined with a positive movement on the Y-axis. We are going to use this principle.
Here I have split up both the horizontal signal and the vertical signal from the joystick, using signal splitters. I hooked each separated signal to its corresponding input of signal combiners to put them back into a composite signal again and feed those into the advanced mover. Why? Good that you ask. We'll be using those splitted signals soon.
Let's focus on the bounding box now. We'll be needing not just one rectangular shape, but four separate pieces in order to distinguish between the upper, lower, left and right boundary. Make them from holographic material set to 0% brightness so that they will be invisible in play or preview mode. Tag each side of our boundary with a unique tag. For instance "North", "East", "South" and "West". Glue everything together so you can easily move the box later if you need to.
Now here is where we put it all together! In between the signal splitters and signal combiners, put an AND gate for each separate signal. So, four total. Hook their output to the signal combiners like in the picture. Also, connect the signals from the splitters to the inputs of the AND gates, just like displayed above.
What we need now is to accompany each of the splitted signals with an impact sensor. One for tag "North" paired with the positive (+) part of the vertical signal. One for tag "South" for the negative part (-) of the vertical signal. "East" goes with the (+) of the horizontal signal and "West" with the (-) of the horizontal signal. Set all the impact sensors to accept touching, but not rigid connections. Also set them to output a reverse signal; this means that they will give off a signal when the moving object is NOT touching the boundary.
Connect each impact sensor's output to an input of the AND gate.
Putting it to the test
What will happen when you jump into the controlinator is that you can now move freely around until you hit a boundary. For instance, you hit "North": the impact sensor for "North" will register and stop giving off a signal, meaning the AND gate with the (+) for vertical movement will be interrupted and there will no longer be any "up" movement put through into the vertical signal combiner. The block will stop moving up. However, all the other signals will be uninterrupted. This means, you can move the block down, sideways, or whatever you like.
No bouncing, no friction, no loss of control. Smoothly!
Results 1 to 20 of 37
How to limit an object's movement to a bounding box, smoothly
aratiatia, Bremnen, Chdonga, CYMBOL, Domik12, Dortr, evret, Jayhawk_er, julesyjules, koltonaugust, Laxen333, lemurboy12, melomaniac, moonwire, Mr_Fusion, Oddmania, OodlesofNoodles, Qrii_Nakari, rialrees, schm0, ShadowTyphoon, shane_danger, Silver39, The Manx Turtle, TheGoldenFlash, Tileno, tomodon246, Ungreth, xero
- Join Date
- Jul 2010
- USA UT
- Blog Entries
Wow, the funny thing is I've seen this so many times but I could never really figure out how it worked haha It could just be my ignorance to all things logic, but anyways... thanks!
the issue with this setup is the fact you lose analog control over the mover, for example you cant hold the stick half way to move half speed, to fix this you need to remove the AND gates from the setup.
in your second picture, put a node in the middle of each of the 4 wires, so each wire goes through it's own node, then move each node into it's own microchip, then connect the inverted impact sensors to the corresponding microchips. this will still behave the same with the bounding box, but you will have full analog control
good point evret, ive used that technique b4 as well
You dont need any of this logic if you use holograms with collision.
heres the thread i posted for it
You can add a material tweaker to the holograms, set physics sounds to none, 0 friction and a rocket rotator to keep it straight. Making the hologram your on a circle will help.
not sure if this would be smoother but wil def save u some logic space. Of course your technique will be more usefull in certain circumstances so thx for the tip.
Last edited by ShadowTyphoon; 05-07-2011 at 01:21 AM.Sky City Coming Soon: I've realeased barely any info on it and the locked backup on my planet has 40+ hearts so far, thx for all support to everyone who has showed interest and to all my friends!
the problem with that is you cant use the layer you use for the cursor and bounding box to build your level, using this logic method is still rather simple but allows you to use all layers as normal for your level.
there is also a glitch that makes neon material invisable, it has slightly different uses to the glitched holo because sackboy collides with it too, not just materials. not sure how to recreate it coz PPp_Killer just gave it to me in create mode and i just corner edit it to the shape i want when i need it
You could create the collisionss to occur in the foreground, and have them stem with normal hologram into the normal dimensions, but i could see how that could end up being a hassle.Sky City Coming Soon: I've realeased barely any info on it and the locked backup on my planet has 40+ hearts so far, thx for all support to everyone who has showed interest and to all my friends!
An example is the camel shooter level in Story Mode, where you control a cursor from the back of a vehicle; the cursor's movement is bound to an invisible box that moves along with the vehicle.
i just did a few tests and yeah your right, AND gates will output the value of the lowest input, aslong as all inputs have some form of active input. i assumed they outputed the highest value like OR gates but had never tested it till now. definitely good to know
Am i right in thinking that this technique could be used to keep my Landspeeder off the ground ?? ........Using just the N & S Holos placed @ top & bottom of the Landspeeder (set to follow a tag on the speeder)
Last edited by Broonba; 05-07-2011 at 06:34 PM.
If you're just trying to keep an object inside of an holo box, you can use a rope and set it to invisible.
One thing for beginners
Just one thing worth knowing to beginners like me:
For this to work you need to set Deceleration to 100% or similar in the Advanced Mover. Otherwise keeps moving through the holo.
I also did a tutorial about this.
Check it out if you want to see how to create it
If anyone finds an effective way to produce this for a moving screen, please tell. My creations with this all rely on the cursor to bounce back off the walls, otherwise you could simply just leave the cursor behind as you move away.
Using a physical means like a string to restrict movement works for this, but an completely logic based method would be nice.Playing LBP Vita. Making a 'FF Tactics - esque' game.
The blocks that making the bounding box in my tutorial can be glued together and moved. You can either move them by logic or glue them to another base object that moves - like the camel in the Story Mode shooter level.
My question is how exactly would you get the cursor to move in step with the moving frame. It can be done for views that move at constant speed, but ineffective for variable AFAIK.Playing LBP Vita. Making a 'FF Tactics - esque' game.
For example, when the frame moves right, the frame sends speed 3 through the Left-Right tag. If you hit the left border, you want to use the positive component of that tag (3) to move right, and if you hit the right border you want the negative component of the tag (-0).
Actually, that's not quite right either. If you hit the left border, you want to use the Left-Right tag speed if the player's speed is less, and if you hit the right border you want to use the Left-Right if the player's speed is greater. Yeah, that sounds about right. Helps thinking backwards.
So uhm, you can take it from here?LBP2 Tutorial: Stretch Objects To Any Height/Width Ratio
Hmmmm I followed all the instructions but its still going through it.... obviously I have done something wrong :/
- Join Date
- Apr 2011
- Blog Entries
He actually had to explain what it did... couldn't really understand HOW it did it.
The cursor can be moved with R Stick and stays in the 'same' spot relative to sackboy, and is limited to how far away it can go.
Still digesting how it works, but it's not up to me to share it, he didn't say top secret, but I don't think its 100% ready.
But, It did inspire me to have a crack at it... well sort of.
In the (scrapped) 2 player version of my stage Miserable Flying Weather, I actually use something to this .
Player 2 can zoom around a screen on a hover board but needed to grab a rope on the DeLorean controlled by player 1. When grabbing a rope attached to Player 1, they lost all control until they let go. Their position stayed the same distance from P1 and if P1 moved they moved with them.
I'll see if I can re-purpose it to be a cursor. In it's current build I'm pretty sure it'll work, but the only thing it won't do is respond to pressing jump. It also relies on using a sackbot.
If I get it working; I'll give it a stupid name and share it.
scorpskull's video next and grab my example to play with.