Hi Nina, thanks for your reply,
After some attempts, here we have the result:
public class BeeFlight : MonoBehaviour
{
[SerializeField] float speed = 1.0f;
Vector3 newPosition;
void Start()
{
PositionChange();
}
void PositionChange() {
newPosition = new Vector2(Random.Range(-5.0f, 5.0f), Random.Range(-5.0f, 5.0f));
if (newPosition.x > transform.position.x) {
transform.localScale = new Vector3(-1, 1, 1);
} else {
transform.localScale = Vector3.one;
}
}
void Update()
{
if (Vector2.Distance(transform.position, newPosition) < 1) {
PositionChange();
}
transform.position = Vector3.Lerp(transform.position, newPosition, Time.deltaTime * speed);
}
}
The sprite now fly randomly from one point to another, facing the right direction, but it moves in line, without some “up and down” that insects usually do while flying
I have to try to add the Rigidbody2D component adding continuously some force from down to up, I think, like you suggested in your reply… uhm…