- Joined
- Aug 3, 2008
- Messages
- 2,345
JASS:
public method projectToPoint (real x, real y, real z, real speed)
{
real dx = x - this.xP,
dy = y - this.yP,
dz = z - this.zP,
len = SquareRoot(dx * dx + dy * dy + dz * dz);
this.xV = speed * dx/len;
this.yV = speed * dy/len;
this.zV = speed * dz/len;
}
Here we have a nice bit of Zinc code. It attempts to project a missile towards a point by setting its velocity to the right values. One problem: it seems to randomly not work sometimes. Any ideas where I'm going wrong with the calculations?
PS: Yes, I'm sure the missile moves based on the velocity correctly, and xP/yP/zP are all set to valid values.