Plant Interaction

To bring the world to life more we want the plants to sway as the player runs past them.

The code below achieves this and is explained afterwards.

Code Purpose:

This code makes the vegetation swing when the player collides with it, based on the player's movement speed and direction. It ensures that the vegetation only swings if the player is moving and it's not already swinging. The swinging motion is smooth and natural, with a back-and-forth effect, giving a more dynamic feel to the environment. 

Action Explained:

Tween one property: Vegetation's "offsetAngle"