So I have an object that once it gets within a certain distance I want to rotate around the object in question. Well, it’s not working. It just continues to move towards.
if(color == "yellow")
{
distance = Vector2.Distance(transform.position, target.transform.position);
if(distance <= scaredRange)
{
transform.RotateAround(target.transform.position, Vector3.up, speed * Time.deltaTime);
}
else
{
transform.rigidbody2D.velocity.x = (target.transform.position.x - transform.position.x) * Time.deltaTime;
}
}
I’m not sure what I did wrong. The distance variable is tracking correctly. So it has to be something with my conditionals.