Skip to main content

Blowinwind

Overview

The Blowinwind component simulates an entity being affected by wind, controlling its movement, rotation, and associated sound. It works by continuously applying a velocity towards a target wind direction, causing the entity to drift and turn smoothly. The movement speed is varied over time to create a more natural, gusting effect. This component requires the entity to also have a locomotor component to handle the actual movement.

Dependencies & Tags

Dependencies:

  • locomotor: Required for the entity to move.
  • SoundEmitter: Required for playing and controlling wind sounds.

Tags:

  • None identified.

Properties

PropertyTypeDefault ValueDescription
maxSpeedMultnumber1.5The maximum speed multiplier applied during speed variation.
minSpeedMultnumber0.5The minimum speed multiplier applied during speed variation.
averageSpeednumber(TUNING.WILSON_RUN_SPEED + TUNING.WILSON_WALK_SPEED)/2The base speed used for movement calculations.
speednumber0The current calculated movement speed of the entity.
windAnglenumber0The target angle (in degrees) of the wind's direction.
windVectorVector3Vector3(0,0,0)The normalized vector representing the target wind direction.
velocityVector3Vector3(0,0,0)The entity's current velocity vector, used for smooth direction changes.
soundParameterstringnilThe FMOD sound parameter to be controlled by the entity's speed.
soundNamestringnilThe name/handle for the sound loop to play while moving.

Main Functions

OnEntitySleep()

  • Description: Automatically stops the component's update loop and sound when the entity goes to sleep.
  • Parameters: None.

OnEntityWake()

  • Description: Automatically restarts the component's update loop and sound when the entity wakes up, using its last known wind angle and velocity.
  • Parameters: None.

StartSoundLoop()

  • Description: Plays the configured sound loop if an inst.SoundEmitter is present and the sound is not already playing.
  • Parameters: None.

StopSoundLoop()

  • Description: Stops the currently playing sound loop.
  • Parameters: None.

Start(ang, vel)

  • Description: Initializes and starts the wind effect, enabling the component's update loop.
  • Parameters:
    • ang (number, optional): The initial angle (in degrees) for the wind direction.
    • vel (number, optional): The initial velocity multiplier.

Stop()

  • Description: Stops the wind effect, halting the component's update loop and any associated sounds.
  • Parameters: None.

ChangeDirection(ang, vel)

  • Description: Updates the target direction of the wind while the component is active.
  • Parameters:
    • ang (number, optional): The new target angle (in degrees) for the wind.
    • vel (number, optional): This parameter is currently unused in the function's logic.

SetMaxSpeedMult(spd)

  • Description: Sets the maximum speed multiplier for wind gusts.
  • Parameters:
    • spd (number): The new maximum speed multiplier.

SetMinSpeedMult(spd)

  • Description: Sets the minimum speed multiplier for wind lulls.
  • Parameters:
    • spd (number): The new minimum speed multiplier.

SetAverageSpeed(spd)

  • Description: Sets the base average speed for movement calculations.
  • Parameters:
    • spd (number): The new average speed.