Last updated
Last updated
Strafing is the act of moving sideways in a video game, typically either in relation to an enemy or the game's camera. Strafing sideways allows a player to keep the camera focused on something, such as an enemy while moving in a different direction.
We created the Strafe component as an addition to the and scripts, with its main aim being to make an object look like it's in the player's hands when they move sideways; It achieves this effect via a clever combination of small movement and rotation changes.
This component creates the desired effect by checking the player's input on every frame and applying a position and rotation force multiplied by the input. It only applies forces when the player is moving, as the value of the input is zero otherwise, and thus the final force will have no value.
As with all the , there is an additional multiplier taken into account besides the player's input, that being the multiplier for this effect.
The main purpose of this effect is to work as an addition on top of others, and thus its functionality is not complex. It can still add a lot of interesting movement to your game by using it though!
There are two main things that you can change when adjusting this effect, those being the position
, which decides how much the object moves as the player moves and in what direction, and the rotation
, which decides how much to rotate and in what direction.
There are also variables for both position and rotation, changing those will make the effect's springs behave differently, and lastly there is the effect's multiplier, which is in the .
When changing the position
and rotation
variables it is best to use small values, as bigger values make the object using the component look like it's moving way too much.