Repository navigation
[DONE] New expressions: "Object.GetXByAngleAndDistance(angle, distance)" and "Object.GetYByAngleAndDistance(angle, distance)" #2367
DescriptionA gamedev knows a vector (angle and distance) and they want to know the endpoint position of the vector. This will be useful for any function that requires a position as input, such as position Tween and Pathfinding. This will make it easy to use tweens for knockback or dashes in any direction. Solution suggestedCreate two new expressions: Object.VectorX(angle, distance) = Given an angle and distance, return the X position of the resulting vector. This can be calculated using trigonometry functions: Object.VectorX(angle, distance) = return Object.X() + (distance * cos(ToRad(angle))) |
Replies: 7 comments 11 replies
|
This would be surely interesting. Note that we have the reverse already:
Note that to be useful in most cases, the Angle and Distance for objects are from the object center. So what you're suggesting is to offer the reverse operation. I'm not sure about two things.
|
|
If we're looking to keep the same naming structure, I'd think "PositionByAngleAndDistance", "Object.PositionByDistanceAndAngle" are both accurate but also relatively long. |
|
Yes that would work even if a bit verbose |
|
I can personally say that adding a Vector expression or whatever you prefer to call it would prove extremely useful to my projects. I, of course, can't speak for others. But it doesn't seem like this would be such a difficult expression to add, and considering how helpful it could prove to be I'm not sure why it can't be added, and sooner rather than later at that. |
|
@4ian Just chiming back in on this as it's come up again on the discord. I think X/YByDistanceAndAngle, or maybe GetX/YByDistanceAndAngle works slightly better and is shorter than Position, but less implicit than x/y? |
|
I can add these new expressions
I can take care of the other points 👍 |
|
@tristanbob These expressions has been added in this pull request. You can try it in lastest nightly builds. Expressions are: This conversation can be marked solved :) |
@tristanbob These expressions has been added in this pull request. You can try it in lastest nightly builds.
Expressions are:
This conversation can be marked solved :)