Fan Code

Create a new event sheet for the Fan

Create a Group for the Vertical Fan

Code Explanation

When the layout starts 

the dust particles associated with the fan are 

not active (not "spraying" or moving).

For every fan in the layout:

If the VerticalFan is overlapping with any FanDustParticle, the following action happens:

The fan stores the unique ID (UID) of the overlapping dust particle in its own instance variable called DustParticlesUID.

Turning the Fans ON and OFF

For every VerticalFan in the layout:

If the Fan's Animation is "Stop"

AND the current particle ID matches the stored ID

The system pauses for 4 seconds.

After 4 seconds, the fan turns on by playing the "On" animation.

The dust particles start spraying.

The system waits for another 4 seconds.

The fan stops again after 4 seconds by playing the "Stop" animation.

The dust particles stop spraying.

If the current animation playing is ON

AND the player is within the boundary of the fans WIDTH

The fan applies a force to the player, affecting the player’s vertical movement (Y vector) based on the fan’s "ForceToApply" value. 

The player's animation is set to a "Jump" animation, indicating that the player is being pushed upwards by the fan. 

How does the code check if the player is within the bounds of the width of the fan?

First Condition:

Player.X > VerticalFan.X - (VerticalFan.Width / 2)

This checks if the player's X position is greater than the left edge of the fan.


VerticalFan.X: The X position of the center of the fan.

VerticalFan.Width / 2: Half of the fan's width, which gives you the distance from the center to the left edge.

So, the expression VerticalFan.X - (VerticalFan.Width / 2) calculates the left edge of the fan. If the player's X position is greater than this value, it means the player is to the right of the left edge.

Second Condition:

Player.X < VerticalFan.X + (VerticalFan.Width / 2)

This checks if the player's X position is less than the right edge of the fan.

VerticalFan.X + (VerticalFan.Width / 2) calculates the right edge of the fan (center of the fan plus half of its width).

If the player's X position is less than this value, it means the player is to the left of the right edge.


Example:

Let’s say the fan's center X position is 500 and its width is 100.


The left edge would be at 500 - (100 / 2) = 450.

The right edge would be at 500 + (100 / 2) = 550.

If the player's X position is between 450 and 550, the conditions will be true, meaning the player is within the fan's area.

Create a group for the Horizontal Fan