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

Rebound logic ?

Archive: 17 posts


http://i.imgur.com/tUspW.jpg

I wish to make a rebounding object. As you can see, the object (near the Start) has to rebound against the frame each time it touches it. This ideal rebound movement can be observed in the pong-like game in the last world of the story mode.

I have no idea where to even start, please help
2011-02-23 20:32:00

Author:
Unknown User


Can you do this with the physics engine? Make the item bouncy and weightless and just bounce it off the walls?

If the object's speed is supposed to be pretty much constant, and it's a rectangular room, you could drive an advanced mover with a couple inputs, and invert one or the other with a direction combiner when you hit a wall - but you'd need to know whether you've hit a horizontal wall or a vertical one, to know which way to rebound.
2011-02-23 21:06:00

Author:
tetsujin
Posts: 187


You just gave me an idea. If there a way to engage a perpetual movement ? I mean, give an impulse to an unmoving object, and the object retains the same speed forever, ignoring air and gravity.2011-02-23 21:33:00

Author:
Unknown User


You just gave me an idea. If there a way to engage a perpetual movement ? I mean, give an impulse to an unmoving object, and the object retains the same speed forever, ignoring air and gravity.

Put a rocket rotator on something, along with a "local space" mover. When you detect a collision (or possibly it might have to be an imminent collision, detected via holo) turn the mover off for a little while, allow the physics engine to handle the collision, give the rocket rotator time to adjust to the new velocity, and then turn the mover back on. Since the mover's in "local space" it'll move according to the object's current heading - which (thanks to the rocket rotator) is determined by its current velocity, which (thanks to the physics engine) has been adjusted by a bounce off a wall.

If you don't want to rotate the item in question, then things get slightly more complicated - you might have to put the rotator and mover on another piece of material and bolt that to the main object, or something...
2011-02-23 21:59:00

Author:
tetsujin
Posts: 187


Put a rocket rotator on something, along with a "local space" mover. When you detect a collision (or possibly it might have to be an imminent collision, detected via holo) turn the mover off for a little while, allow the physics engine to handle the collision, give the rocket rotator time to adjust to the new velocity, and then turn the mover back on. Since the mover's in "local space" it'll move according to the object's current heading - which (thanks to the rocket rotator) is determined by its current velocity, which (thanks to the physics engine) has been adjusted by a bounce off a wall.

This is exactly how I am doing it in a level I'm working on, works like a charm. All it needs is the collision detection, you don't have to predict the collision.
2011-02-23 22:10:00

Author:
Osprey71
Posts: 93


EDIT: See above2011-02-23 22:10:00

Author:
SSTAGG1
Posts: 1136


The "local space" puzzled me a lot though I didn't bother looking for what it meant. Thanks a lot ! I'll give it a try tomorrow.2011-02-23 23:30:00

Author:
Unknown User


The "local space" puzzled me a lot though I didn't bother looking for what it meant.

Basically, once you've set the direction for a mover, "local space" controls whether the mover's direction rotates with the object or not. (If you gave a rocket a mover that makes it move upward in "local space" - and then you turn the rocket sideways, the rocket will go sideways. But if the mover were not set for local space (meaning it's set for global space instead) - then you could turn it sideways, upside-down, whatever, and it'd still move up.
2011-02-23 23:38:00

Author:
tetsujin
Posts: 187


I think I'll have to beg for some more help. I've tried using a rocket rotator and a mover, but I have a problem : when the object is not moving, the rocket rotator does nothing - and when my "target" reaches one border of the frame, it stops, and the rocket rotator doesn't rotate the object, therefore the object is still stuck.
It appears I don't get that logic at all. If you could point at a copiable level that has this kind of rebound logic, this would really be appreciated !
2011-03-01 23:42:00

Author:
Unknown User


I think I'll have to beg for some more help. I've tried using a rocket rotator and a mover, but I have a problem : when the object is not moving, the rocket rotator does nothing - and when my "target" reaches one border of the frame, it stops, and the rocket rotator doesn't rotate the object, therefore the object is still stuck.
It appears I don't get that logic at all. If you could point at a copiable level that has this kind of rebound logic, this would really be appreciated !

Did you also make the object bouncy, and set up an impact sensor and timer to turn off the mover for a short period after a collision?

(EDIT): I gave this a try: for bouncy, weightless objects it works well with a very short timer delay after each collision. It's also important to set the rotator to a high speed, so that it quickly snaps to its new direction after a collision, so the mover (when it turns back on) will move in the right direction. It's also fun to put this on sackbots - I set up a bunch of sackbots in the box, dressed 'em as ninjas, and made them do the "ninja yell" sound after each bounce. Good times.
2011-03-01 23:47:00

Author:
tetsujin
Posts: 187


for doing it with a vertically and horizontally walled surface, there is a very simple way. Glue four pieces of holo onto a square; one each for north, south, east and west. Then use four impact sensors. Then when any of the pieces make contact, invert the direction of movement across the perpendicular axis.

In other word, if it hits on the top make it start moving down, on the left make it move right. Just inverting one direction like that gives it a "bouncing" effect.
2011-03-02 04:11:00

Author:
tdarb
Posts: 689


Have you set Material Tweakers on both the walls and ball? Ball needs to be 100% bouncy, 0% friction (and a 100% anti-grav, 0% dampening object as well). The walls need to have 0% friction as well. This should create a perpetual motion for the ball.

Above comments are useful for if you'd like to influence the velocity/direction of the ball with logic. As a matter of fact, I am going to dig into this advice myself, right away!
2011-03-02 13:27:00

Author:
Antikris
Posts: 1340


Have you set Material Tweakers on both the walls and ball? Ball needs to be 100% bouncy, 0% friction (and a 100% anti-grav, 0% dampening object as well). The walls need to have 0% friction as well. This should create a perpetual motion for the ball.

Actually the walls, or any other object beside the ball, don't need to be modified at all. I have this technique working perfectly for my needs. Once I finish my level I'll give away a microchip with the logic as a prize but here is my setup:

Your bullet/projectile should be a circle shape (or a sphere-like object like one of the ball objects), place a microchip in it's exact center and place all logic on the chip.

Tweak the material properties to 100% bounce, 0% Friction and Antigrav to 100%, Dampening 0% seems to work best as well.
Place a Rocket Rotator and set to max speed, it will always be on. This rotates your projectile to the direction it is traveling in.
Wire an impact sensor to start a timer [ Target time = .1, Input Action = Start Count Down, Invert Output = Yes]
Wire the timer into a Thruster, set the thruster to be the desired constant speed of your projectile.

That's pretty much it.

I typically set the projectile to emit at the same speed as the thruster, and make sure they are both going the same direction when you emit it

What happens is, the thruster maintains the speed of the projectile and the rotator is constantly aiming the thrust to maintain the heading. When the projectile impacts any object the thruster is turned off momentarily so that the rotator can fix in it's new bearing and then the thruster kicks back in. If the thruster were on the whole time the projectile would curve while the rotator was spinning and the impact trajectory would be lost. If your projectile is still curving slightly, increase the Target Time on the timer to .2 (but I've found that .1 works in every test I've done as long as the rocket rotator is at max speed).

Occasionally the projectile can get a bit of a boost from a collision, it will speed up momentarily, you can play with the Dampening and/or the Acceleration/Deceleration of the Thruster to try to alleviate that.
2011-03-02 20:45:00

Author:
Osprey71
Posts: 93


That's pretty much it.

Good writeup. Going to give your setup a go later, as I have been pondering about an Arcanoid level myself recently. I wonder, though, are the thruster settings so much balanced out that you'd not go and influence the balls velocity with logic (like, in an Arcanoid/Breakout game)?

About the short increase in speed after impact, wouldn't a 100% deceleration setting on the mover (thruster) fix that the instant it becomes active again?
2011-03-03 09:47:00

Author:
Antikris
Posts: 1340


Good writeup. Going to give your setup a go later, as I have been pondering about an Arcanoid level myself recently. I wonder, though, are the thruster settings so much balanced out that you'd not go and influence the balls velocity with logic (like, in an Arcanoid/Breakout game)?

About the short increase in speed after impact, wouldn't a 100% deceleration setting on the mover (thruster) fix that the instant it becomes active again?

You should be able to control the velocity via logic, I've been messing with the velocity of my bullets (trying to find the most aesthetic speed) while creating my level and I haven't had to change anything else.

Yes you can set deceleration to 100% and that should instantly snap it back to your desired speed, though the speed increase would still be visible during the time the thruster is inactive. I actually don't mind it slowing down smoothly over a fraction of a second it can have a pleasing effect. The speed increase really only comes into play when the projectile impacts an object that is moving towards it. If the collision object is stationary it behaves as expected. Of course, the opposite is true as well, if the collision object is moving away from the projectile there will be a momentary slow down, but this seems to be less noticeable. I have seen some odd behavior when the projectile impacts something that is going almost the same speed and direction as itself, it can go off in a random direction, but this is a very rare occurrence (at least in my level) and the behavior doesn't really bother me.
2011-03-03 19:40:00

Author:
Osprey71
Posts: 93


Wouldn't making the walls bouncy work? Just saying.2011-03-04 00:05:00

Author:
L1N3R1D3R
Posts: 13447


Wouldn't making the walls bouncy work? Just saying.

If you followed the thread you would know that that solution won't work. There is drag in the system and the object will eventually slow down and stop.
2011-03-04 01:07:00

Author:
Osprey71
Posts: 93


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.