Table of Contents

set gravity to x () y ()

Description

The block sets the gravity for the physics engine in the defined x and y directions. To simulate Earth’s gravity, the value should be X to 0 and Y to -10. 

Let’s see how gravity changes the output of the Physics Engine:

Gravity in X as 0 & Y as -10

Gravity in X as 0 & Y as -4

Gravity in X as 0 & Y as -2

Gravity in X as 0 & Y as 0

Gravity in X as 0 & Y as 2

Gravity in X as 10 & Y as -10

Example

The example demonstrates how to make a sprite be fixed to a point but can rotate. The wand is hanging like a pendulum.

The example demonstrates how to make a sprite be fixed to a point but can rotate. The wand is hanging like a pendulum.

The center of the wand in the costume is the point of rotation.

The following code creates the simulation of the pendulum.

Output

Read More
In this example, you understand the effect of the density, roughness, and bounce properties of the sprites. The ball falls from the top randomly, and the bell is fixed but can rotate. 

In this example, you understand the effect of the density, roughness, and bounce properties of the sprites. The ball falls from the top randomly, and the bell is fixed but can rotate.

Script of Bell

The bell center is changed to make it swing from the top.

Script for Ball

This script creates clones of the ball every 0.5 seconds.

This script assigns the properties of the clone.

Output

We will change the density of the bell and the ball in the block – set sprite density () roughness () bounce (). This will result in different simulations.

  1. Bell is very light and the balls are very heavy: The inertia of the balls will affect the bell too much.
  2. Bell is very light and balls are also very light: The bell is less affected by the ball. Gradually the bell slows down.
  3. Bell is very heavy and the balls are very light: The bell is not affected at all. The balls are thrown without adding any effect on the bell.
  4. Bell is very heavy and the balls are also very heavy: Same as option 2 – The bell is less affected by the ball. Gradually the bell slows down.
Read More
In this example, we will analyze the effect of the bounce property of the sprite using a ball. We will track the ball using the pen extension and the color will change with the y velocity of the ball.

In this example, we will analyze the effect of the bounce property of the sprite using a ball. We will track the ball using the pen extension and the color will change with the y velocity of the ball.

The coefficient of restitution is the ratio of the final to the initial relative speed between two objects after they collide. In PictoBlox it is controlled with bounce property. It varies from 0 to 100%.

The following is the code we will use:

Let’s see how the code work will various bounce values:

  1. Bounce = 10
  2. Bounce = 60
  3. Bounce = 70
  4. Bounce = 80
  5. Bounce = 90
  6. Bounce = 99

Earth vs Moon

If we change the gravity with a bounce value equal to 90, we can simulate how the ball will work on the moon.

Read More
In this example, we simulate the covid experiment using the physics simulation.

In this example, we simulate the covid experiment using the physics simulation. Following is what we are doing:

  1. 21 humans are created with 20 green and 1 red ball.
  2. Gravity is set to 0 simulating zero gravity.
  3. The balls move at random speeds constantly creating random behavior.
  4. If the green balls touch the red balls, it turns red.
  5. After 10 seconds the red ball gets converted to green.

Script

Output

Read More
All articles loaded
No more articles to load