Trying to create multiple-reactions with objects

I am trying to create a specific multi-reaction when one object collides with another. I am racking my brain but cannot think of a good way to make it work. The background info is as follows:

I have two objects, a ball, and a cloud

The ball is an object that bounces around. Currently the cloud is set to float across the screen but remains static.

The idea is for the ball to bounce off of the top of the cloud.

The problem is that, with a static cloud, the ball also bounces if it hits the bottom of the cloud. 

I thought about making the cloud a sensor so that it would allow the ball to pass through on the bottom and then turn static so that it would bounce on the top, but that won’t keep the ball from being able to bounce on the bottom the next time it happens, or stop the ball from simply falling through the top of the cloud the first time.

I also thought that if I make the top of the cloud static and the bottom of the cloud a sensor that this might do it, but the result is that the ball just bounces off of the middle of the cloud from the bottom. It is a real pain in the rear. 

now I am thinking the best thing to do is write a function that has a way to call different reaction based on the ball’s direction of travel, but I cannot think of a viable way to do so that will work with the static cloud on collision. 

Any suggestions would be appreciated. Please help. :slight_smile:

Hi @rhino19001,

This seems like a “one-sided platform” kind of scenario, so you might want to consider a PhysicsContact pre-collision handler for this, sensing the ball’s position in regards to the cloud. If it’s above, you choose to handle the collision… if not, you simply ignore the collision entirely. You can view a demo and sample code on this in my Physics Contact tutorial here:

http://www.coronalabs.com/blog/2012/11/27/introducing-physics-event-contact/

Best regards,

Brent

that is a perfect suggestion for the one sided platform. Can’t believe I didn’t consider that. Thanks Brent

Hi @rhino19001,

This seems like a “one-sided platform” kind of scenario, so you might want to consider a PhysicsContact pre-collision handler for this, sensing the ball’s position in regards to the cloud. If it’s above, you choose to handle the collision… if not, you simply ignore the collision entirely. You can view a demo and sample code on this in my Physics Contact tutorial here:

http://www.coronalabs.com/blog/2012/11/27/introducing-physics-event-contact/

Best regards,

Brent

that is a perfect suggestion for the one sided platform. Can’t believe I didn’t consider that. Thanks Brent