angle2vector?
![TwistedMech](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
hi
I want to get an X and Y position based on an Angle+distance from start point. This would be used to fire an object from the player to a direction set using the joystick template (right stick).
This could be used in a game to move an object using interpolate x,y.
I found some code which looks like it performs the calculation but need to find a GameSalad equivalent for "toRadians". It would be nice to have a command Angle2Vector.
Anyone have any ideas?
private Point2D.Double getPoint(double angle, double distance) {
// Angles in java are measured clockwise from 3 o'clock.
double theta = Math.toRadians(angle);
Point2D.Double p = new Point2D.Double();
p.x = center.x + distance*Math.cos(theta);
p.y = center.y + distance*Math.sin(theta);
return p;
I want to get an X and Y position based on an Angle+distance from start point. This would be used to fire an object from the player to a direction set using the joystick template (right stick).
This could be used in a game to move an object using interpolate x,y.
I found some code which looks like it performs the calculation but need to find a GameSalad equivalent for "toRadians". It would be nice to have a command Angle2Vector.
Anyone have any ideas?
private Point2D.Double getPoint(double angle, double distance) {
// Angles in java are measured clockwise from 3 o'clock.
double theta = Math.toRadians(angle);
Point2D.Double p = new Point2D.Double();
p.x = center.x + distance*Math.cos(theta);
p.y = center.y + distance*Math.sin(theta);
return p;
Comments
angle in radians = angle in degrees * Pi / 180
but if you know your distance and the angle you can use
x=distance*(cos(angle))
y=distance*(sin(angle))
but I might be wrong so just going to check
Or am I just missing the whole point of this thread?