SetVelocity2DAction - CodingDino/Dino-Unity-Toolkit GitHub Wiki

The SetVelocity2DAction component changes the velocity of a Rigidbody2D component attached to the same GameObject. When you attach this component, the Rigidbody2D will automatically be attached as well. You will not be able to remove the Rigidbody2D component while the SetVelocity2DAction is attached.

This is an Action component, and therefore must be triggered by a separate Activator component. Actions, Activators, and Data make up the core system for the Dino Unity Toolkit.

Image: SetVelocity2DAction set up with a speed multiplier of 5.

Image: SetVelocity2DAction attached to a square which moves when a button is pressed using an InputAxisActivator.

Properties

Property: Description:
Speed Multiplier used to alter velocity sent from Activators. Use 1 to leave velocities unaltered.

Actions

This component has several Action functions that can be triggered by Activators.

ActionSetVelocity()

This will set both the x and y portions of the velocity, using a vector. The Speed parameter on the SetVelocity2DAction will be multiplied by the x and y portions of the velocity.

Parameter: Description:
New Velocity Both the x and y components of the new velocity.

ActionSetXVelocity()

This will set only the x velocity on the Rigidbody2D - the y velocity will remain unaltered. Use this for horizontal movement, that will still allow the player to fall or jump. The Speed parameter on the SetVelocity2DAction will be multiplied by the supplied x velocity.

Parameter: Description:
New X Velocity The new x portion of the velocity.

ActionSetYVelocity()

This will set only the y velocity on the Rigidbody2D - the x velocity will remain unaltered. Use this for steady vertical movement. The Speed parameter on the SetVelocity2DAction will be multiplied by the supplied y velocity.

Parameter: Description:
New Y Velocity The new y portion of the velocity.