我正在尝试随机化我的路径搜索器代码。目前,运行以下代码的sprite将移向目标。但是,我希望抛射物略微高于或低于目标。我尝试改变我的矢量点,但它似乎没有工作。有什么建议吗?
//从怪物到目标获取矢量 CGPoint vectorToTarget = vectorSubtract(self.target.position,projectile.position);
CGPoint randomVector = CGPointMake(vectorToTarget.x + ((int)arc4random_uniform(51) - 25), vectorToTarget.y + ((int)arc4random_uniform(51) - 25));
//Make unit vector
CGPoint direction = vectorNormalize(randomVector);
CGPoint shootDistance = vectorMultiplyByScalar(direction, self.screenSize.height+self.screenSize.width);
CGPoint actualDistance = vectorAdd(shootDistance, self.position);
float velocity = 100.0/1.0;
float time = self.screenSize.width / velocity;
SKAction *actionMove = [SKAction moveTo:actualDistance duration:time];