You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Modifying a vector by applying some operation (addition, subtraction, etc) is currently really verbose.
Imagine you want to animate the position of node by moving it by [200, 400] relative to its current position:
On top of that, a new edit method should be introduced to derive the new value in whatever way necessary:
// this:node.position.add([200,400]);// is the same as this:node.position.edit(current=>current.add([200,400]));
While on itself still pretty verbose, this interface would allow you to create reusable functions for operations that are not natively supported.
Imagine you want to snap the vector to a 20x20 grid:
// define a reusable method:functionsnap(grid: PossibleVector2){return(current: Vector2)=>current.div(grid).floored.mul(grid);}// use it:node.position.edit(snap(20));
The text was updated successfully, but these errors were encountered:
Description
Modifying a vector by applying some operation (addition, subtraction, etc) is currently really verbose.
Imagine you want to animate the position of
node
by moving it by[200, 400]
relative to its current position:In general, whenever we want to derive the new value of a signal using its current value things become verbose.
Proposed solution
Introduce a set of methods for Vector2 signals that reflect the operations of the
Vector2
class.These could be used to either tween or immediately modify the signal, just like you normally would:
On top of that, a new
edit
method should be introduced to derive the new value in whatever way necessary:While on itself still pretty verbose, this interface would allow you to create reusable functions for operations that are not natively supported.
Imagine you want to snap the vector to a
20x20
grid:The text was updated successfully, but these errors were encountered: