Colliding and moving


#1

41 AM

My student is trying to get his object (Bugs) to move to a location when it collides with the object (Rabbit) This is the code he’s using but it isn’t working. Any suggestions?


#2

Hi Mary,

your student is trying to use a block from the Transitions-category on a physics item (the Bugs-item). Currently, physics items can only be moved with blocks found in the Physics-category. In the example above, the move block will be ignored by the Bugs-item. We’re working on making it more clear what kind of blocks can be used with physics items.

Below are possible solutions for your student’s problem:

Solution
When the bug collides with the rabbit, disable the rabbit’s collision and then push it up. This prevents the bug from spinning around when the rabbit jumps. Then, push the bug into a new position with the push (item) towards position block.

This is how the code looks like in action:
Bugs_Code_1

Since the bug is moved quickly into another direction, he flips over. To prevent this, we can lock the rotation of a physics-item with the restrict block from the Physics -> Properties category. Below is the updated code where we restrict the Bug rotation.

This is how the new code looks like in action:
Bugs_Code_2

Hope this helps your student finding an approach to this problem by using physics blocks!


#3

Thank you so much!! My fifth graders are loving using cospaces! It’s the most excited theyve been all year!