Home Game Development How so as to add steering conduct to motion

How so as to add steering conduct to motion

0
How so as to add steering conduct to motion

[ad_1]

I’ve applied a easy mechanism to maneuver an object in the direction of a goal

double velocity = 5;
double velocityX = vacation spot.x - supply.x;
double velocityY = vacation spot.y - supply.y;
if (velocityX == 0) {
  velocityY = velocity;
} else if (velocityY == 0) {
  velocityX = velocity;
} else {
  velocityX = (velocityX / distance) * velocity;
  velocityY = (velocityY / distance) * velocity;
}

supply.x += velocityX;
supply.y += velocityY;

which works effective to date. Additionally, I want to add some type of “steering” in order that the motion is not going to immediately go in the direction of the goal however in a slight curve which may be modified by way of an attribute. So principally the item is meant to comply with a path and I would like my algorithm to make clean curves as an alternative of relatively edgy actions from level to level.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here